about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/trans/closure.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index 380a512d17b..252a10f8a8b 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -409,6 +409,15 @@ pub fn trans_expr_fn(bcx: block,
                                                  ~"expr_fn");
     let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
 
+    // Always mark inline if this is a loop body. This is important for
+    // performance on many programs with tight loops.
+    if is_loop_body.is_some() {
+        set_always_inline(llfn);
+    } else {
+        // Can't hurt.
+        set_inline_hint(llfn);
+    }
+
     let Result {bcx: bcx, val: closure} = match sigil {
         ast::BorrowedSigil | ast::ManagedSigil | ast::OwnedSigil => {
             let cap_vars = *ccx.maps.capture_map.get(&user_id);