Mercurial > projects > ldc
annotate gen/optimizer.cpp @ 1541:1e7a09548e67
Target.addPassesToEmitFile takes a formatted_raw_ostream now
Build fix for LLVM r75670
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Tue, 14 Jul 2009 23:06:31 +0200 |
parents | d1652c8fb4f6 |
children | 259b031f3d22 |
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" |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
2 #include "gen/cl_helpers.h" |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
3 |
1275
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
4 #include "gen/passes/Passes.h" |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
5 |
125 | 6 #include "llvm/PassManager.h" |
7 #include "llvm/LinkAllPasses.h" | |
8 #include "llvm/Analysis/LoopPass.h" | |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
9 #include "llvm/Analysis/Verifier.h" |
125 | 10 #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
|
11 #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
|
12 #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
|
13 |
1172
b3887714b735
Small cleanup: remove mars.h #include
Frits van Bommel <fvbommel wxs.nl>
parents:
1171
diff
changeset
|
14 #include "root.h" // error() |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
15 #include <cstring> // strcmp(); |
125 | 16 |
17 using namespace llvm; | |
18 | |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
19 // 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
|
20 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
|
21 passList( |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
22 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
|
23 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
|
24 ); |
125 | 25 |
1281
29d3861aa2da
Make sure this still compiles after LLVM r70437, which introduces a
Frits van Bommel <fvbommel wxs.nl>
parents:
1275
diff
changeset
|
26 static cl::opt<unsigned char> optimizeLevel( |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
27 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
|
28 cl::ZeroOrMore, |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
29 cl::values( |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
30 clEnumValN(2, "O", "Equivalent to -O2"), |
1171
461a85f0db31
Change meaning of optimization levels: -O0 now means 'no optimization' like with
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
31 clEnumValN(0, "O0", "No optimizations (default)"), |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 clEnumValEnd), |
1171
461a85f0db31
Change meaning of optimization levels: -O0 now means 'no optimization' like with
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
38 cl::init(0)); |
125 | 39 |
1275
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
40 static cl::opt<bool> |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
41 verifyEach("verify-each", |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
42 cl::desc("Run verifier after each optimization pass"), |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
43 cl::Hidden, |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
44 cl::ZeroOrMore); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
45 |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
46 static cl::opt<bool> |
1275
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
47 disableLangSpecificPasses("disable-d-passes", |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
48 cl::desc("Disable D-specific passes in -O<N>"), |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
49 cl::ZeroOrMore); |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
50 |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
51 static cl::opt<bool> |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
52 disableSimplifyRuntimeCalls("disable-simplify-drtcalls", |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
53 cl::desc("Disable simplification of runtime calls in -O<N>"), |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
54 cl::ZeroOrMore); |
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
55 |
1285
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
56 static cl::opt<bool> |
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
57 disableGCToStack("disable-gc2stack", |
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
58 cl::desc("Disable promotion of GC allocations to stack memory in -O<N>"), |
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
59 cl::ZeroOrMore); |
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
60 |
1287
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
61 // Not recommended; metadata currently triggers an assert in the backend... |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
62 static cl::opt<bool> |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
63 disableStripMetaData("disable-strip-metadata", |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
64 cl::desc("Disable default metadata stripping (not recommended)"), |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
65 cl::ZeroOrMore); |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
66 |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
67 static cl::opt<opts::BoolOrDefaultAdapter, false, opts::FlagParser> |
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
68 enableInlining("inlining", |
1275
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
69 cl::desc("(*) Enable function inlining in -O<N>"), |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
70 cl::ZeroOrMore); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
71 |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
72 // Determine whether or not to run the inliner as part of the default list of |
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
73 // optimization passes. |
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
74 // If not explicitly specified, treat as false for -O0-2, and true for -O3. |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
75 bool doInline() { |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
76 return enableInlining == cl::BOU_TRUE |
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
77 || (enableInlining == cl::BOU_UNSET && optimizeLevel >= 3); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
78 } |
131 | 79 |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
80 // Determine whether the inliner will be run. |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
81 bool willInline() { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
82 if (doInline()) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
83 return true; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
84 // It may also have been specified explicitly on the command line as an explicit pass |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
85 typedef cl::list<const PassInfo*, bool, PassNameParser> PL; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
86 for (PL::iterator I = passList.begin(), E = passList.end(); I != E; ++I) { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
87 if (!std::strcmp((*I)->getPassArgument(), "inline")) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
88 return true; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
89 } |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
90 return false; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
91 } |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
92 |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
93 // Some extra accessors for the linker: (llvm-ld version only, currently unused?) |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
94 int optLevel() { |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
95 return optimizeLevel; |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
96 } |
125 | 97 |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
98 bool optimize() { |
1267 | 99 return optimizeLevel || doInline() || !passList.empty(); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
100 } |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
101 |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
102 static void addPass(PassManager& pm, Pass* pass) { |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
103 pm.add(pass); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
104 |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
105 if (verifyEach) pm.add(createVerifierPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
106 } |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
107 |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
108 // 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
|
109 // 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
|
110 static void addPassesForOptLevel(PassManager& pm) { |
1171
461a85f0db31
Change meaning of optimization levels: -O0 now means 'no optimization' like with
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
111 // -O1 |
461a85f0db31
Change meaning of optimization levels: -O0 now means 'no optimization' like with
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
112 if (optimizeLevel >= 1) |
131 | 113 { |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
114 //addPass(pm, createStripDeadPrototypesPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
115 addPass(pm, createGlobalDCEPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
116 addPass(pm, createRaiseAllocationsPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
117 addPass(pm, createCFGSimplificationPass()); |
1219
a0844cc67840
Tweak some optimizations.
Frits van Bommel <fvbommel wxs.nl>
parents:
1175
diff
changeset
|
118 if (optimizeLevel == 1) |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
119 addPass(pm, createPromoteMemoryToRegisterPass()); |
1219
a0844cc67840
Tweak some optimizations.
Frits van Bommel <fvbommel wxs.nl>
parents:
1175
diff
changeset
|
120 else |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
121 addPass(pm, createScalarReplAggregatesPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
122 addPass(pm, createGlobalOptimizerPass()); |
125 | 123 } |
124 | |
131 | 125 // -O2 |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
126 if (optimizeLevel >= 2) |
125 | 127 { |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
128 addPass(pm, createIPConstantPropagationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
129 addPass(pm, createDeadArgEliminationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
130 addPass(pm, createInstructionCombiningPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
131 addPass(pm, createCFGSimplificationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
132 addPass(pm, createPruneEHPass()); |
1423
42bd767ec5a4
* Add -functionattrs to default pass list so -dgc2stack is more effective
Frits van Bommel <fvbommel wxs.nl>
parents:
1296
diff
changeset
|
133 addPass(pm, createFunctionAttrsPass()); |
1472
a28953f1eb43
Move `-tailcallelim` to a place in the optimization sequence where it seems to
Frits van Bommel <fvbommel wxs.nl>
parents:
1423
diff
changeset
|
134 addPass(pm, createTailCallEliminationPass()); |
a28953f1eb43
Move `-tailcallelim` to a place in the optimization sequence where it seems to
Frits van Bommel <fvbommel wxs.nl>
parents:
1423
diff
changeset
|
135 addPass(pm, createCFGSimplificationPass()); |
1506
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
136 addPass(pm, createGVNPass()); |
125 | 137 } |
138 | |
131 | 139 // -inline |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
140 if (doInline()) { |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
141 addPass(pm, createFunctionInliningPass()); |
1288
e109e4031e8a
Fix build when USE_METADATA is off.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents:
1287
diff
changeset
|
142 |
1219
a0844cc67840
Tweak some optimizations.
Frits van Bommel <fvbommel wxs.nl>
parents:
1175
diff
changeset
|
143 if (optimizeLevel >= 2) { |
a0844cc67840
Tweak some optimizations.
Frits van Bommel <fvbommel wxs.nl>
parents:
1175
diff
changeset
|
144 // Run some optimizations to clean up after inlining. |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
145 addPass(pm, createScalarReplAggregatesPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
146 addPass(pm, createInstructionCombiningPass()); |
1506
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
147 // -instcombine + gvn == devirtualization :) |
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
148 addPass(pm, createGVNPass()); |
1288
e109e4031e8a
Fix build when USE_METADATA is off.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents:
1287
diff
changeset
|
149 |
1506
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
150 // Inline again, to catch things like now nonvirtual |
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
151 // function calls, foreach delegates passed to inlined |
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
152 // opApply's, etc. where the actual function being called |
76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
Frits van Bommel <fvbommel wxs.nl>
parents:
1492
diff
changeset
|
153 // wasn't known during the first inliner pass. |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
154 addPass(pm, createFunctionInliningPass()); |
1219
a0844cc67840
Tweak some optimizations.
Frits van Bommel <fvbommel wxs.nl>
parents:
1175
diff
changeset
|
155 } |
125 | 156 } |
157 | |
1507
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
158 if (optimizeLevel >= 2) { |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
159 if (!disableLangSpecificPasses) { |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
160 if (!disableSimplifyRuntimeCalls) |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
161 addPass(pm, createSimplifyDRuntimeCalls()); |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
162 |
1288
e109e4031e8a
Fix build when USE_METADATA is off.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents:
1287
diff
changeset
|
163 #ifdef USE_METADATA |
1507
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
164 if (!disableGCToStack) |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
165 addPass(pm, createGarbageCollect2Stack()); |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
166 #endif |
1285
91d9386d4a5a
Implement another D-specific pass: -dgc2stack
Frits van Bommel <fvbommel wxs.nl>
parents:
1281
diff
changeset
|
167 } |
1507
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
168 // Run some clean-up passes |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
169 addPass(pm, createInstructionCombiningPass()); |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
170 addPass(pm, createScalarReplAggregatesPass()); |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
171 addPass(pm, createCFGSimplificationPass()); |
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
172 addPass(pm, createInstructionCombiningPass()); |
1275
bedf0bfb8fdb
Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents:
1268
diff
changeset
|
173 } |
1507
f86fd3b77285
Eliminate comparisons between GC allocations and constants. This removes some
Frits van Bommel <fvbommel wxs.nl>
parents:
1506
diff
changeset
|
174 |
131 | 175 // -O3 |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
176 if (optimizeLevel >= 3) |
125 | 177 { |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
178 addPass(pm, createArgumentPromotionPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
179 addPass(pm, createTailDuplicationPass()); |
1492
ef76f6e1693c
Add some passes that `opt` runs to the default pass list.
Frits van Bommel <fvbommel wxs.nl>
parents:
1486
diff
changeset
|
180 addPass(pm, createSimplifyLibCallsPass()); |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
181 addPass(pm, createInstructionCombiningPass()); |
1492
ef76f6e1693c
Add some passes that `opt` runs to the default pass list.
Frits van Bommel <fvbommel wxs.nl>
parents:
1486
diff
changeset
|
182 addPass(pm, createJumpThreadingPass()); |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
183 addPass(pm, createCFGSimplificationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
184 addPass(pm, createScalarReplAggregatesPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
185 addPass(pm, createInstructionCombiningPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
186 addPass(pm, createCondPropagationPass()); |
125 | 187 |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
188 addPass(pm, createReassociatePass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
189 addPass(pm, createLoopRotatePass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
190 addPass(pm, createLICMPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
191 addPass(pm, createLoopUnswitchPass()); |
1492
ef76f6e1693c
Add some passes that `opt` runs to the default pass list.
Frits van Bommel <fvbommel wxs.nl>
parents:
1486
diff
changeset
|
192 addPass(pm, createLoopIndexSplitPass()); |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
193 addPass(pm, createInstructionCombiningPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
194 addPass(pm, createIndVarSimplifyPass()); |
1492
ef76f6e1693c
Add some passes that `opt` runs to the default pass list.
Frits van Bommel <fvbommel wxs.nl>
parents:
1486
diff
changeset
|
195 addPass(pm, createLoopDeletionPass()); |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
196 addPass(pm, createLoopUnrollPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
197 addPass(pm, createInstructionCombiningPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
198 addPass(pm, createGVNPass()); |
1481
e0f03e11cdf8
Add `-memcpyopt` to the optimization pass list.
Frits van Bommel <fvbommel wxs.nl>
parents:
1472
diff
changeset
|
199 addPass(pm, createMemCpyOptPass()); |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
200 addPass(pm, createSCCPPass()); |
125 | 201 |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
202 addPass(pm, createInstructionCombiningPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
203 addPass(pm, createCondPropagationPass()); |
125 | 204 |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
205 addPass(pm, createDeadStoreEliminationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
206 addPass(pm, createAggressiveDCEPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
207 addPass(pm, createCFGSimplificationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
208 addPass(pm, createDeadTypeEliminationPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
209 addPass(pm, createConstantMergePass()); |
125 | 210 } |
211 | |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
212 if (optimizeLevel >= 1) { |
1483
defafbabbe32
Add a pass to strip the bodies of `available_externally` functions so string
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
213 addPass(pm, createStripExternalsPass()); |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
214 addPass(pm, createGlobalDCEPass()); |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
215 } |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1481
diff
changeset
|
216 |
131 | 217 // 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
|
218 } |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
219 |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
220 ////////////////////////////////////////////////////////////////////////////////////////// |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
221 // 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
|
222 // 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
|
223 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
|
224 { |
1287
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
225 if (!optimize()) { |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
226 if (!disableStripMetaData) { |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
227 // This one always needs to run if metadata is generated, because |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
228 // the code generator will assert if it's not used. |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
229 ModulePass* stripMD = createStripMetaData(); |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
230 stripMD->runOnModule(*m); |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
231 delete stripMD; |
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
232 } |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
233 return false; |
1287
6c8af78364f5
There's an issue with LLVM metadata support; it triggers an assert when trying
Frits van Bommel <fvbommel wxs.nl>
parents:
1285
diff
changeset
|
234 } |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
235 |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
236 PassManager pm; |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
237 |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
238 if (verifyEach) pm.add(createVerifierPass()); |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
239 |
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
240 addPass(pm, new TargetData(m)); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
241 |
1175
cc1efa23030a
Enable inlining by default for -O3+.
Frits van Bommel <fvbommel wxs.nl>
parents:
1172
diff
changeset
|
242 bool optimize = optimizeLevel != 0 || doInline(); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
243 |
1171
461a85f0db31
Change meaning of optimization levels: -O0 now means 'no optimization' like with
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
244 unsigned optPos = optimizeLevel != 0 |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
245 ? optimizeLevel.getPosition() |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
246 : enableInlining.getPosition(); |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
247 |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
248 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
|
249 // 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
|
250 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
|
251 addPassesForOptLevel(pm); |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
252 optimize = false; |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
253 } |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
254 |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
255 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
|
256 if (PassInfo::NormalCtor_t ctor = pass->getNormalCtor()) { |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
257 addPass(pm, ctor()); |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
258 } else { |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
259 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
|
260 if (arg) |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
261 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
|
262 else |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
263 error("Can't create pass (%s)", pass->getPassName()); |
1172
b3887714b735
Small cleanup: remove mars.h #include
Frits van Bommel <fvbommel wxs.nl>
parents:
1171
diff
changeset
|
264 assert(0); // Should be unreachable; root.h:error() calls exit() |
1170
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
265 } |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
266 } |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
267 // 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
|
268 if (optimize) |
e40c65bd8c5d
Allow specific optimization passes to be requested from the command line.
Frits van Bommel <fvbommel wxs.nl>
parents:
663
diff
changeset
|
269 addPassesForOptLevel(pm); |
125 | 270 |
1294
dd84ec4353ce
Strip metadata even when addPassesForOptLevel() isn't called, for instance when
Frits van Bommel <fvbommel wxs.nl>
parents:
1288
diff
changeset
|
271 if (!disableStripMetaData) { |
dd84ec4353ce
Strip metadata even when addPassesForOptLevel() isn't called, for instance when
Frits van Bommel <fvbommel wxs.nl>
parents:
1288
diff
changeset
|
272 // This one is purposely not disabled by disableLangSpecificPasses |
dd84ec4353ce
Strip metadata even when addPassesForOptLevel() isn't called, for instance when
Frits van Bommel <fvbommel wxs.nl>
parents:
1288
diff
changeset
|
273 // because the code generator will assert if it's not used. |
1296
79b201533cf8
Add -verify-each option to ease debugging
Frits van Bommel <fvbommel wxs.nl>
parents:
1294
diff
changeset
|
274 addPass(pm, createStripMetaData()); |
1294
dd84ec4353ce
Strip metadata even when addPassesForOptLevel() isn't called, for instance when
Frits van Bommel <fvbommel wxs.nl>
parents:
1288
diff
changeset
|
275 } |
dd84ec4353ce
Strip metadata even when addPassesForOptLevel() isn't called, for instance when
Frits van Bommel <fvbommel wxs.nl>
parents:
1288
diff
changeset
|
276 |
131 | 277 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
|
278 return true; |
125 | 279 } |