Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1485:9344fecd24f0 | 1486:9ed0695cb93c |
---|---|
131 addPass(pm, createDeadArgEliminationPass()); | 131 addPass(pm, createDeadArgEliminationPass()); |
132 addPass(pm, createInstructionCombiningPass()); | 132 addPass(pm, createInstructionCombiningPass()); |
133 addPass(pm, createCFGSimplificationPass()); | 133 addPass(pm, createCFGSimplificationPass()); |
134 addPass(pm, createPruneEHPass()); | 134 addPass(pm, createPruneEHPass()); |
135 addPass(pm, createFunctionAttrsPass()); | 135 addPass(pm, createFunctionAttrsPass()); |
136 | |
137 #ifdef USE_METADATA | |
138 if (!disableLangSpecificPasses && !disableGCToStack) | |
139 addPass(pm, createGarbageCollect2Stack()); | |
140 #endif | |
141 | |
142 addPass(pm, createTailCallEliminationPass()); | 136 addPass(pm, createTailCallEliminationPass()); |
143 addPass(pm, createCFGSimplificationPass()); | 137 addPass(pm, createCFGSimplificationPass()); |
144 } | 138 } |
145 | 139 |
146 // -inline | 140 // -inline |
149 | 143 |
150 if (optimizeLevel >= 2) { | 144 if (optimizeLevel >= 2) { |
151 // Run some optimizations to clean up after inlining. | 145 // Run some optimizations to clean up after inlining. |
152 addPass(pm, createScalarReplAggregatesPass()); | 146 addPass(pm, createScalarReplAggregatesPass()); |
153 addPass(pm, createInstructionCombiningPass()); | 147 addPass(pm, createInstructionCombiningPass()); |
154 | |
155 #ifdef USE_METADATA | |
156 if (!disableLangSpecificPasses && !disableGCToStack) | |
157 addPass(pm, createGarbageCollect2Stack()); | |
158 #endif | |
159 | 148 |
160 // Inline again, to catch things like foreach delegates | 149 // Inline again, to catch things like foreach delegates |
161 // passed to inlined opApply's where the function wasn't | 150 // passed to inlined opApply's where the function wasn't |
162 // known during the first inliner pass. | 151 // known during the first inliner pass. |
163 addPass(pm, createFunctionInliningPass()); | 152 addPass(pm, createFunctionInliningPass()); |
164 | 153 |
165 // Run clean-up again. | 154 // Run clean-up again. |
166 addPass(pm, createScalarReplAggregatesPass()); | 155 addPass(pm, createScalarReplAggregatesPass()); |
167 addPass(pm, createInstructionCombiningPass()); | 156 addPass(pm, createInstructionCombiningPass()); |
168 | |
169 #ifdef USE_METADATA | |
170 if (!disableLangSpecificPasses && !disableGCToStack) | |
171 addPass(pm, createGarbageCollect2Stack()); | |
172 #endif | |
173 } | 157 } |
174 } | 158 } |
175 | 159 |
176 if (optimizeLevel >= 2 && !disableLangSpecificPasses) { | 160 if (optimizeLevel >= 2 && !disableLangSpecificPasses) { |
177 if (!disableSimplifyRuntimeCalls) | 161 if (!disableSimplifyRuntimeCalls) |
178 addPass(pm, createSimplifyDRuntimeCalls()); | 162 addPass(pm, createSimplifyDRuntimeCalls()); |
179 | 163 |
180 #ifdef USE_METADATA | 164 #ifdef USE_METADATA |
181 if (!disableGCToStack) { | 165 if (!disableGCToStack) { |
182 // Run some clean-up after the last GC to stack promotion pass. | 166 addPass(pm, createGarbageCollect2Stack()); |
183 addPass(pm, createScalarReplAggregatesPass()); | 167 // Run some clean-up |
184 addPass(pm, createInstructionCombiningPass()); | 168 addPass(pm, createInstructionCombiningPass()); |
169 addPass(pm, createScalarReplAggregatesPass()); | |
185 addPass(pm, createCFGSimplificationPass()); | 170 addPass(pm, createCFGSimplificationPass()); |
186 } | 171 } |
187 #endif | 172 #endif |
188 } | 173 } |
189 | 174 |