mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 19:06:02 +03:00
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:
parent
1ef9941daf
commit
5ea141e919
1 changed files with 19 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue