Skip to content

Commit

Permalink
std: Flag run_fmt() as #[inline(always)]
Browse files Browse the repository at this point in the history
This function is a tiny wrapper that LLVM doesn't want to inline, and it ends up
causing more bloat than necessary. The bloat is pretty small, but it's a win of
at least 7k for small executables, and I imagine that the number goes up as
there are more calls to fail!().
  • Loading branch information
alexcrichton committed Feb 28, 2014
1 parent 79e6ab5 commit ddc1c21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ macro_rules! fail(
// function to pass to format_args!, *and* we need the
// file and line numbers right here; so an inner bare fn
// is our only choice.
#[inline]
//
// LLVM doesn't tend to inline this, presumably because begin_unwind_fmt
// is #[cold] and #[inline(never)] and because this is flagged as cold
// as returning !. We really do want this to be inlined, however,
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
// were seen when forcing this to be inlined, and that number just goes
// up with the number of calls to fail!()
#[inline(always)]
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
::std::rt::begin_unwind_fmt(fmt, file!(), line!())
}
Expand Down

5 comments on commit ddc1c21

@bors
Copy link
Contributor

@bors bors commented on ddc1c21 Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at alexcrichton@ddc1c21

@bors
Copy link
Contributor

@bors bors commented on ddc1c21 Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/size = ddc1c21 into auto

@bors
Copy link
Contributor

@bors bors commented on ddc1c21 Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/size = ddc1c21 merged ok, testing candidate = 5b4a141

@bors
Copy link
Contributor

@bors bors commented on ddc1c21 Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on ddc1c21 Feb 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5b4a141

Please sign in to comment.