diff gen/optimizer.cpp @ 1486:9ed0695cb93c

Teach `-dgc2stack` to promote GC allocations in simple loops to stack allocations too. (A "simple" loop is one where the allocation isn't used in a subsequent iteration) This also means it's no longer necessary to run this pass multiple times. Running it once after inlining should now catch all cases.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 08 Jun 2009 12:35:55 +0200
parents defafbabbe32
children ef76f6e1693c
line wrap: on
line diff
--- a/gen/optimizer.cpp	Sun Jun 07 23:00:53 2009 +0200
+++ b/gen/optimizer.cpp	Mon Jun 08 12:35:55 2009 +0200
@@ -133,12 +133,6 @@
         addPass(pm, createCFGSimplificationPass());
         addPass(pm, createPruneEHPass());
         addPass(pm, createFunctionAttrsPass());
-
-#ifdef USE_METADATA
-        if (!disableLangSpecificPasses && !disableGCToStack)
-            addPass(pm, createGarbageCollect2Stack());
-#endif
-
         addPass(pm, createTailCallEliminationPass());
         addPass(pm, createCFGSimplificationPass());
     }
@@ -152,11 +146,6 @@
             addPass(pm, createScalarReplAggregatesPass());
             addPass(pm, createInstructionCombiningPass());
 
-#ifdef USE_METADATA
-            if (!disableLangSpecificPasses && !disableGCToStack)
-                addPass(pm, createGarbageCollect2Stack());
-#endif
-
             // Inline again, to catch things like foreach delegates
             // passed to inlined opApply's where the function wasn't
             // known during the first inliner pass.
@@ -165,11 +154,6 @@
             // Run clean-up again.
             addPass(pm, createScalarReplAggregatesPass());
             addPass(pm, createInstructionCombiningPass());
-
-#ifdef USE_METADATA
-            if (!disableLangSpecificPasses && !disableGCToStack)
-                addPass(pm, createGarbageCollect2Stack());
-#endif
         }
     }
 
@@ -179,9 +163,10 @@
 
 #ifdef USE_METADATA
         if (!disableGCToStack) {
-            // Run some clean-up after the last GC to stack promotion pass.
+            addPass(pm, createGarbageCollect2Stack());
+            // Run some clean-up
+            addPass(pm, createInstructionCombiningPass());
             addPass(pm, createScalarReplAggregatesPass());
-            addPass(pm, createInstructionCombiningPass());
             addPass(pm, createCFGSimplificationPass());
         }
 #endif