Mercurial > projects > ldc
comparison gen/optimizer.cpp @ 1576:4551475bc6b6
Kill off StripMetaData.
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Tue, 25 Aug 2009 21:35:43 +0200 |
parents | 3adcb70700cb |
children | 40bd4a0d4870 |
comparison
equal
deleted
inserted
replaced
1575:299a6b634178 | 1576:4551475bc6b6 |
---|---|
56 static cl::opt<bool> | 56 static cl::opt<bool> |
57 disableGCToStack("disable-gc2stack", | 57 disableGCToStack("disable-gc2stack", |
58 cl::desc("Disable promotion of GC allocations to stack memory in -O<N>"), | 58 cl::desc("Disable promotion of GC allocations to stack memory in -O<N>"), |
59 cl::ZeroOrMore); | 59 cl::ZeroOrMore); |
60 | 60 |
61 // Not recommended; metadata currently triggers an assert in the backend... | |
62 static cl::opt<bool> | |
63 disableStripMetaData("disable-strip-metadata", | |
64 cl::desc("Disable default metadata stripping (not recommended)"), | |
65 cl::ZeroOrMore); | |
66 | |
67 static cl::opt<opts::BoolOrDefaultAdapter, false, opts::FlagParser> | 61 static cl::opt<opts::BoolOrDefaultAdapter, false, opts::FlagParser> |
68 enableInlining("inlining", | 62 enableInlining("inlining", |
69 cl::desc("(*) Enable function inlining in -O<N>"), | 63 cl::desc("(*) Enable function inlining in -O<N>"), |
70 cl::ZeroOrMore); | 64 cl::ZeroOrMore); |
71 | 65 |
220 ////////////////////////////////////////////////////////////////////////////////////////// | 214 ////////////////////////////////////////////////////////////////////////////////////////// |
221 // This function runs optimization passes based on command line arguments. | 215 // This function runs optimization passes based on command line arguments. |
222 // Returns true if any optimization passes were invoked. | 216 // Returns true if any optimization passes were invoked. |
223 bool ldc_optimize_module(llvm::Module* m) | 217 bool ldc_optimize_module(llvm::Module* m) |
224 { | 218 { |
225 if (!optimize()) { | 219 if (!optimize()) |
226 #if USE_METADATA | |
227 if (!disableStripMetaData) { | |
228 // This one always needs to run if metadata is generated, because | |
229 // the code generator will assert if it's not used. | |
230 ModulePass* stripMD = createStripMetaData(); | |
231 stripMD->runOnModule(*m); | |
232 delete stripMD; | |
233 } | |
234 #endif | |
235 return false; | 220 return false; |
236 } | |
237 | 221 |
238 PassManager pm; | 222 PassManager pm; |
239 | 223 |
240 if (verifyEach) pm.add(createVerifierPass()); | 224 if (verifyEach) pm.add(createVerifierPass()); |
241 | 225 |
268 } | 252 } |
269 // insert -O<N> / -enable-inlining if specified at the end, | 253 // insert -O<N> / -enable-inlining if specified at the end, |
270 if (optimize) | 254 if (optimize) |
271 addPassesForOptLevel(pm); | 255 addPassesForOptLevel(pm); |
272 | 256 |
273 #if USE_METADATA | |
274 if (!disableStripMetaData) { | |
275 // This one is purposely not disabled by disableLangSpecificPasses | |
276 // because the code generator will assert if it's not used. | |
277 addPass(pm, createStripMetaData()); | |
278 } | |
279 #endif // USE_METADATA | |
280 | |
281 pm.run(*m); | 257 pm.run(*m); |
282 return true; | 258 return true; |
283 } | 259 } |