Mercurial > projects > ldc
comparison gen/optimizer.cpp @ 129:8096ba7082db trunk
[svn r133] Fixed some problems with inlining not happening :P
Fixed problems with certain cases of deeply nested classes/functions.
author | lindquist |
---|---|
date | Fri, 28 Dec 2007 22:55:24 +0100 |
parents | c42d245468ea |
children | 5825d48b27d1 |
comparison
equal
deleted
inserted
replaced
128:e5fe8521bbfa | 129:8096ba7082db |
---|---|
11 // optimization level given. | 11 // optimization level given. |
12 | 12 |
13 void llvmdc_optimize_module(Module* m, char lvl, bool doinline) | 13 void llvmdc_optimize_module(Module* m, char lvl, bool doinline) |
14 { | 14 { |
15 assert(lvl >= 0 && lvl <= 5); | 15 assert(lvl >= 0 && lvl <= 5); |
16 if (lvl == 0) | |
17 return; | |
18 | 16 |
19 PassManager pm; | 17 PassManager pm; |
20 pm.add(new TargetData(m)); | 18 pm.add(new TargetData(m)); |
21 | 19 |
22 if (lvl >= 1) | 20 if (lvl >= 1) |
23 { | 21 { |
24 pm.add(createRaiseAllocationsPass()); | 22 pm.add(createRaiseAllocationsPass()); |
25 pm.add(createCFGSimplificationPass()); | 23 pm.add(createCFGSimplificationPass()); |
26 pm.add(createPromoteMemoryToRegisterPass()); | 24 pm.add(createPromoteMemoryToRegisterPass()); |
25 pm.add(createGlobalOptimizerPass()); | |
26 pm.add(createGlobalDCEPass()); | |
27 } | 27 } |
28 | 28 |
29 if (lvl >= 2) | 29 if (lvl >= 2) |
30 { | 30 { |
31 pm.add(createGlobalOptimizerPass()); | |
32 pm.add(createGlobalDCEPass()); | |
33 pm.add(createIPConstantPropagationPass()); | 31 pm.add(createIPConstantPropagationPass()); |
34 pm.add(createDeadArgEliminationPass()); | 32 pm.add(createDeadArgEliminationPass()); |
35 pm.add(createInstructionCombiningPass()); | 33 pm.add(createInstructionCombiningPass()); |
36 pm.add(createCFGSimplificationPass()); | 34 pm.add(createCFGSimplificationPass()); |
37 pm.add(createPruneEHPass()); | 35 pm.add(createPruneEHPass()); |
75 pm.add(createConstantMergePass()); | 73 pm.add(createConstantMergePass()); |
76 } | 74 } |
77 | 75 |
78 // level 4 and 5 are linktime optimizations | 76 // level 4 and 5 are linktime optimizations |
79 | 77 |
80 pm.run(*m); | 78 if (lvl > 0 || doinline) |
79 pm.run(*m); | |
81 } | 80 } |