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.
This commit is contained in:
Frits van Bommel
2009-06-08 12:35:55 +02:00
parent f7ab031c7e
commit b999f679a7
2 changed files with 117 additions and 34 deletions

View File

@@ -133,12 +133,6 @@ static void addPassesForOptLevel(PassManager& pm) {
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 @@ static void addPassesForOptLevel(PassManager& pm) {
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 @@ static void addPassesForOptLevel(PassManager& pm) {
// Run clean-up again.
addPass(pm, createScalarReplAggregatesPass());
addPass(pm, createInstructionCombiningPass());
#ifdef USE_METADATA
if (!disableLangSpecificPasses && !disableGCToStack)
addPass(pm, createGarbageCollect2Stack());
#endif
}
}
@@ -179,9 +163,10 @@ static void addPassesForOptLevel(PassManager& pm) {
#ifdef USE_METADATA
if (!disableGCToStack) {
// Run some clean-up after the last GC to stack promotion pass.
addPass(pm, createScalarReplAggregatesPass());
addPass(pm, createGarbageCollect2Stack());
// Run some clean-up
addPass(pm, createInstructionCombiningPass());
addPass(pm, createScalarReplAggregatesPass());
addPass(pm, createCFGSimplificationPass());
}
#endif