From 31d65453d47f243635ea17563db6b2c1127e9836 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 19 May 2011 12:46:10 -0700 Subject: OptLevel changes. Accepts levels 0 to 3 only. '-O' is synonym for --OptLevel=2. --- src/comp/back/link.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/comp/back') diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 09a4079b1f8..d0e6b5a7c6f 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -101,7 +101,7 @@ mod write { if (opts.save_temps) { alt (opts.output_type) { case (output_type_bitcode) { - if (opts.optimize) { + if (opts.optimize != 0u) { auto filename = mk_intermediate_name(output, "no-opt.bc"); llvm::LLVMWriteBitcodeToFile(llmod, @@ -121,22 +121,26 @@ mod write { // -Os, etc // FIXME3: Should we expose and use the pass lists used by the opt // tool? - if (opts.optimize) { + if (opts.optimize != 0u) { auto fpm = mk_pass_manager(); llvm::LLVMAddTargetData(td.lltd, fpm.llpm); llvm::LLVMAddStandardFunctionPasses(fpm.llpm, 2u); llvm::LLVMRunPassManager(fpm.llpm, llmod); - // TODO: On -O3, use 275 instead of 225 for the inlining - // threshold. + let uint threshold = 225u; + if (opts.optimize == 3u) { + threshold = 275u; + } + llvm::LLVMAddStandardModulePasses(pm.llpm, - 2u, // optimization level - False, // optimize for size - True, // unit-at-a-time - True, // unroll loops - True, // simplify lib calls - True, // have exceptions - 225u); // inlining threshold + // optimization level + opts.optimize, + False, // optimize for size + True, // unit-at-a-time + True, // unroll loops + True, // simplify lib calls + True, // have exceptions + threshold); // inline threshold } if (opts.verify) { -- cgit 1.4.1-3-g733a5