Skip to content

Commit 0b0ca59

Browse files
committed
librustc: Improve inlining behavior.
1 parent ca8e99f commit 0b0ca59

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc/middle/trans/closure.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,15 @@ pub fn trans_expr_fn(bcx: block,
409409
~"expr_fn");
410410
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
411411

412+
// Always mark inline if this is a loop body. This is important for
413+
// performance on many programs with tight loops.
414+
if is_loop_body.is_some() {
415+
set_always_inline(llfn);
416+
} else {
417+
// Can't hurt.
418+
set_inline_hint(llfn);
419+
}
420+
412421
let Result {bcx: bcx, val: closure} = match sigil {
413422
ast::BorrowedSigil | ast::ManagedSigil | ast::OwnedSigil => {
414423
let cap_vars = *ccx.maps.capture_map.get(&user_id);

0 commit comments

Comments
 (0)