Tweak some optimizations.

Delegates passed to inlined functions now also stand a chance of being inlined.
This should make opApply as efficient as a regular loop, as long as both opApply
and the foreachbody are eligible for inlining; which is to say most non-virtual
opApply invocations will likely get fully inlined now.
(Note: above requires -O2 -enable-inlining or -O3)
This commit is contained in:
Frits van Bommel 2009-04-16 11:58:43 +02:00
parent 1ef9941daf
commit 5ea141e919

View file

@ -65,7 +65,10 @@ static void addPassesForOptLevel(PassManager& pm) {
pm.add(createGlobalDCEPass());
pm.add(createRaiseAllocationsPass());
pm.add(createCFGSimplificationPass());
pm.add(createPromoteMemoryToRegisterPass());
if (optimizeLevel == 1)
pm.add(createPromoteMemoryToRegisterPass());
else
pm.add(createScalarReplAggregatesPass());
pm.add(createGlobalOptimizerPass());
pm.add(createGlobalDCEPass());
}
@ -83,6 +86,21 @@ static void addPassesForOptLevel(PassManager& pm) {
// -inline
if (doInline()) {
pm.add(createFunctionInliningPass());
if (optimizeLevel >= 2) {
// Run some optimizations to clean up after inlining.
pm.add(createInstructionCombiningPass());
pm.add(createScalarReplAggregatesPass());
// Inline again, to catch things like foreach delegates
// passed inlined opApply's where the function wasn't
// known during the first inliner pass.
pm.add(createFunctionInliningPass());
// Run clean-up again.
pm.add(createInstructionCombiningPass());
pm.add(createScalarReplAggregatesPass());
}
}
// -O3