annotate gen/optimizer.cpp @ 1170:e40c65bd8c5d

Allow specific optimization passes to be requested from the command line. Now you can run "`ldc test.d -c -mem2reg -simplifycfg`" if you feel the urge. The -O<N> options are still supported, and are inserted in the passes list in the position where they appear on the command line. (so -simplifycfg -O1 -instcombine does the "right thing") One small change: -inline is renamed to -enable-inlining due to a naming conflict with the option to add the -inline pass. -inline now inserts the inlining pass in the position specified, not in the middle of -O<N>. (ldmd has been updated to translate -inline to -enable-inlining)
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 29 Mar 2009 15:46:55 +0200
parents 6aaa3d3c1183
children 461a85f0db31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
1 #include "gen/optimizer.h"
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
2
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
3 #include "llvm/PassManager.h"
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
4 #include "llvm/LinkAllPasses.h"
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
5 #include "llvm/Analysis/LoopPass.h"
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
6 #include "llvm/Target/TargetData.h"
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
7 #include "llvm/Support/CommandLine.h"
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
8 #include "llvm/Support/PassNameParser.h"
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
9
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
10 #include "root.h" // error() & fatal()
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
11 #include "mars.h" // global flags
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
12
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
13 using namespace llvm;
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
14
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
15 // Allow the user to specify specific optimizations to run.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
16 static cl::list<const PassInfo*, bool, PassNameParser>
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
17 passList(
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
18 cl::desc("Running specific optimizations:"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
19 cl::Hidden // to clean up --help output
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
20 );
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
21
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
22 static cl::opt<char> optimizeLevel(
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
23 cl::desc("Setting the optimization level:"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
24 cl::ZeroOrMore,
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
25 cl::values(
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
26 clEnumValN(2, "O", "Equivalent to -O2"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
27 clEnumValN(0, "O0", "Trivial optimizations only"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
28 clEnumValN(1, "O1", "Simple optimizations"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
29 clEnumValN(2, "O2", "Good optimizations"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
30 clEnumValN(3, "O3", "Aggressive optimizations"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
31 clEnumValN(4, "O4", "Link-time optimization"), // not implemented?
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
32 clEnumValN(5, "O5", "Link-time optimization"), // not implemented?
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
33 clEnumValEnd),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
34 cl::init(-1));
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
35
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
36 static cl::opt<bool> enableInlining("enable-inlining",
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
37 cl::desc("Enable function inlining (in -O<N>, if given)"),
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
38 cl::ZeroOrMore,
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
39 cl::init(false));
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
40
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
41 // Some accessors for the linker: (llvm-ld version only, currently unused?)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
42 bool doInline() {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
43 return enableInlining;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
44 }
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
45
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
46 int optLevel() {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
47 return optimizeLevel;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
48 }
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
49
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
50 bool optimize() {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
51 return (optimizeLevel != -1) || enableInlining || passList.empty();
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
52 }
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
53
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
54 // this function inserts some or all of the std-compile-opts passes depending on the
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
55 // optimization level given.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
56 static void addPassesForOptLevel(PassManager& pm) {
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
57 // -O0
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
58 if (optimizeLevel >= 0)
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
59 {
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
60 //pm.add(createStripDeadPrototypesPass());
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
61 pm.add(createGlobalDCEPass());
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
62 }
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
63
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
64 // -O1
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
65 if (optimizeLevel >= 1)
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
66 {
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
67 pm.add(createRaiseAllocationsPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
68 pm.add(createCFGSimplificationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
69 pm.add(createPromoteMemoryToRegisterPass());
129
8096ba7082db [svn r133] Fixed some problems with inlining not happening :P
lindquist
parents: 125
diff changeset
70 pm.add(createGlobalOptimizerPass());
8096ba7082db [svn r133] Fixed some problems with inlining not happening :P
lindquist
parents: 125
diff changeset
71 pm.add(createGlobalDCEPass());
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
72 }
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
73
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
74 // -O2
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
75 if (optimizeLevel >= 2)
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
76 {
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
77 pm.add(createIPConstantPropagationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
78 pm.add(createDeadArgEliminationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
79 pm.add(createInstructionCombiningPass());
607
9526b29ae342 Fixed the optimizer thing, since llvm PR 2800 is already fixed, users need to upgrade LLVM to latest svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 605
diff changeset
80 pm.add(createCFGSimplificationPass());
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
81 pm.add(createPruneEHPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
82 }
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
83
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
84 // -inline
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
85 if (enableInlining) {
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
86 pm.add(createFunctionInliningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
87 }
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
88
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
89 // -O3
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
90 if (optimizeLevel >= 3)
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
91 {
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
92 pm.add(createArgumentPromotionPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
93 pm.add(createTailDuplicationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
94 pm.add(createInstructionCombiningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
95 pm.add(createCFGSimplificationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
96 pm.add(createScalarReplAggregatesPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
97 pm.add(createInstructionCombiningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
98 pm.add(createCondPropagationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
99
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
100 pm.add(createTailCallEliminationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
101 pm.add(createCFGSimplificationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
102 pm.add(createReassociatePass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
103 pm.add(createLoopRotatePass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
104 pm.add(createLICMPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
105 pm.add(createLoopUnswitchPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
106 pm.add(createInstructionCombiningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
107 pm.add(createIndVarSimplifyPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
108 pm.add(createLoopUnrollPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
109 pm.add(createInstructionCombiningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
110 pm.add(createGVNPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
111 pm.add(createSCCPPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
112
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
113 pm.add(createInstructionCombiningPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
114 pm.add(createCondPropagationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
115
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
116 pm.add(createDeadStoreEliminationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
117 pm.add(createAggressiveDCEPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
118 pm.add(createCFGSimplificationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
119 pm.add(createSimplifyLibCallsPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
120 pm.add(createDeadTypeEliminationPass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
121 pm.add(createConstantMergePass());
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
122 }
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
123
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
124 // level -O4 and -O5 are linktime optimizations
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
125 }
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
126
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
127 //////////////////////////////////////////////////////////////////////////////////////////
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
128 // This function runs optimization passes based on command line arguments.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
129 // Returns true if any optimization passes were invoked.
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
130 bool ldc_optimize_module(llvm::Module* m)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
131 {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
132 if (!enableInlining && optimizeLevel == -1 && passList.empty())
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
133 return false;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
134
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
135 PassManager pm;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
136 pm.add(new TargetData(m));
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
137
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
138 bool optimize = (optimizeLevel != -1) || enableInlining;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
139
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
140 unsigned optPos = optimizeLevel != -1
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
141 ? optimizeLevel.getPosition()
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
142 : enableInlining.getPosition();
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
143
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
144 for (size_t i = 0; i < passList.size(); i++) {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
145 // insert -O<N> / -enable-inlining in right position
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
146 if (optimize && optPos < passList.getPosition(i)) {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
147 addPassesForOptLevel(pm);
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
148 optimize = false;
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
149 }
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
150
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
151 const PassInfo* pass = passList[i];
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
152 if (PassInfo::NormalCtor_t ctor = pass->getNormalCtor()) {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
153 pm.add(ctor());
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
154 } else {
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
155 const char* arg = pass->getPassArgument(); // may return null
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
156 if (arg)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
157 error("Can't create pass '-%s' (%s)", arg, pass->getPassName());
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
158 else
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
159 error("Can't create pass (%s)", pass->getPassName());
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
160 fatal();
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
161 }
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
162 }
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
163 // insert -O<N> / -enable-inlining if specified at the end,
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
164 if (optimize)
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
165 addPassesForOptLevel(pm);
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
166
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
167 pm.run(*m);
1170
e40c65bd8c5d Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents: 663
diff changeset
168 return true;
125
c42d245468ea [svn r129] Started AA literals.
lindquist
parents:
diff changeset
169 }