about summary refs log tree commit diff
path: root/src/comp/back
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-05-19 12:46:10 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-05-19 12:46:10 -0700
commit31d65453d47f243635ea17563db6b2c1127e9836 (patch)
treed63a3d6512237883b35b908c756177fb241f3e1c /src/comp/back
parent0a74ffaea336177ab65b92d578a187d1388857e3 (diff)
downloadrust-31d65453d47f243635ea17563db6b2c1127e9836.tar.gz
rust-31d65453d47f243635ea17563db6b2c1127e9836.zip
OptLevel changes. Accepts levels 0 to 3 only. '-O' is synonym for --OptLevel=2.
Diffstat (limited to 'src/comp/back')
-rw-r--r--src/comp/back/link.rs26
1 files changed, 15 insertions, 11 deletions
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) {