[llvm-commits] [dragonegg] r102706 - /dragonegg/trunk/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Fri Apr 30 02:47:23 PDT 2010


Author: baldrick
Date: Fri Apr 30 04:47:23 2010
New Revision: 102706

URL: http://llvm.org/viewvc/llvm-project?rev=102706&view=rev
Log:
In dragonegg, LLVM initialization occurs late enough that the
Ada frontend will already have set flag_exceptions beforehand.
So handle flag_exceptions the same as other flags.

Modified:
    dragonegg/trunk/llvm-backend.cpp

Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=102706&r1=102705&r2=102706&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Fri Apr 30 04:47:23 2010
@@ -80,6 +80,7 @@
 #include "tree-flow.h"
 #include "tree-pass.h"
 #include "version.h"
+#include "except.h"
 }
 
 // Plugin headers
@@ -333,13 +334,8 @@
 #undef Declare2
 }
 
-/// LazilyConfigureLLVM - Set LLVM configuration options, if not already set.
-/// already created.
-static void LazilyConfigureLLVM(void) {
-  static bool Configured = false;
-  if (Configured)
-    return;
-
+/// ConfigureLLVM - Initialized and configure LLVM.
+static void ConfigureLLVM(void) {
   // Initialize the LLVM backend.
 #define DoInit2(TARG, MOD)  LLVMInitialize ## TARG ## MOD()
 #define DoInit(T, M) DoInit2(T, M)
@@ -394,6 +390,12 @@
     Args.push_back("--ffunction-sections");
   if (flag_data_sections)
     Args.push_back("--fdata-sections");
+  if (flag_exceptions) {
+    if (USING_SJLJ_EXCEPTIONS)
+      Args.push_back("--enable-sjlj-eh");
+    else
+      Args.push_back("--enable-eh");
+  }
 
   // If there are options that should be passed through to the LLVM backend
   // directly from the command line, do so now.  This is mainly for debugging
@@ -431,8 +433,6 @@
   Args.push_back(0);  // Null terminator.
   int pseudo_argc = Args.size()-1;
   llvm::cl::ParseCommandLineOptions(pseudo_argc, const_cast<char**>(&Args[0]));
-
-  Configured = true;
 }
 
 /// LazilyInitializeModule - Create a module to output LLVM IR to, if it wasn't
@@ -442,7 +442,7 @@
   if (Initialized)
     return;
 
-  LazilyConfigureLLVM();
+  ConfigureLLVM();
 
   TheModule = new Module("", getGlobalContext());
 
@@ -529,25 +529,7 @@
     TheDebugInfo = new DebugInfo(TheModule);
   if (TheDebugInfo)
     TheDebugInfo->Initialize();
-//TODO}
-//TODO
-//TODO/// performLateBackendInitialization - Set backend options that may only be
-//TODO/// known at codegen time.
-//TODOvoid performLateBackendInitialization(void) {
-//TODO  // The Ada front-end sets flag_exceptions only after processing the file.
-//TODO  if (USING_SJLJ_EXCEPTIONS)
-//TODO    SjLjExceptionHandling = flag_exceptions;
-//TODO  else
-//TODO    DwarfExceptionHandling = flag_exceptions;
-//TODO  for (Module::iterator I = TheModule->begin(), E = TheModule->end();
-//TODO       I != E; ++I)
-//TODO    if (!I->isDeclaration()) {
-//TODO      if (flag_disable_red_zone)
-//TODO        I->addFnAttr(Attribute::NoRedZone);
-//TODO      if (flag_no_implicit_float)
-//TODO        I->addFnAttr(Attribute::NoImplicitFloat);
-//TODO    }
-//TODO}
+
   Initialized = true;
 }
 
@@ -1585,7 +1567,6 @@
   }
 
   if (!errorcount && !sorrycount) { // Do not process broken code.
-    // TODO  performLateBackendInitialization();
     createPerFunctionOptimizationPasses();
 
     if (PerFunctionPasses)
@@ -2025,7 +2006,6 @@
 //TODO  timevar_push(TV_LLVM_PERFILE);
   LLVMContext &Context = getGlobalContext();
 
-//TODO  performLateBackendInitialization();
   createPerFunctionOptimizationPasses();
 //TODO
 //TODO  if (flag_pch_file) {
@@ -2033,6 +2013,15 @@
 //TODO    writeLLVMValues();
 //TODO  }
 
+//TODO  for (Module::iterator I = TheModule->begin(), E = TheModule->end();
+//TODO       I != E; ++I)
+//TODO    if (!I->isDeclaration()) {
+//TODO      if (flag_disable_red_zone)
+//TODO        I->addFnAttr(Attribute::NoRedZone);
+//TODO      if (flag_no_implicit_float)
+//TODO        I->addFnAttr(Attribute::NoImplicitFloat);
+//TODO    }
+
   // Add an llvm.global_ctors global if needed.
   if (!StaticCtors.empty())
     CreateStructorsList(StaticCtors, "llvm.global_ctors");





More information about the llvm-commits mailing list