diff gen/main.cpp @ 1482:d9c5f5a43403

Run `semantic3` on imported modules, and emit new symbols with `available_externally` linkage. This allows the inliner to inline functions from other modules while telling the code generator to ignore those functions (treat them as declarations) Still generates a few extra `TypeInfo`s and strings... Disabled when generating debug info because I don't really understand it, and it doesn't like this.
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 07 Jun 2009 16:00:13 +0200
parents a5526b7a5ae6
children 7d3b47852a7a
line wrap: on
line diff
--- a/gen/main.cpp	Sun Jun 07 15:07:29 2009 +0200
+++ b/gen/main.cpp	Sun Jun 07 16:00:13 2009 +0200
@@ -35,6 +35,7 @@
 #include "gen/logger.h"
 #include "gen/linker.h"
 #include "gen/irstate.h"
+#include "gen/optimizer.h"
 #include "gen/toobj.h"
 #include "gen/metadata.h"
 #include "gen/passes/Passes.h"
@@ -811,6 +812,17 @@
          * not be found at link time.
          */
         if (!global.params.useArrayBounds && !global.params.useAssert)
+#elif LLVM_REV >= 68940
+    // This doesn't play nice with debug info at the moment
+    if (!global.params.symdebug && willInline())
+    {
+        global.params.useAvailableExternally = true;
+        Logger::println("Running some extra semantic3's for inlining purposes");
+#else
+    // IN_LLVM, but available_externally not available yet.
+    if (false)
+    {
+#endif
         {
             // Do pass 3 semantic analysis on all imported modules,
             // since otherwise functions in them cannot be inlined
@@ -825,6 +837,7 @@
                 fatal();
         }
 
+#if !IN_LLVM
         for (int i = 0; i < modules.dim; i++)
         {
             m = (Module *)modules.data[i];
@@ -832,10 +845,10 @@
                 printf("inline scan %s\n", m->toChars());
             m->inlineScan();
         }
+#endif
     }
     if (global.errors)
         fatal();
-#endif
 
     // write module dependencies to file if requested
     if (global.params.moduleDepsFile != NULL)