Skip to content

Commit ddc1c21

Browse files
committed
std: Flag run_fmt() as #[inline(always)]
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!().
1 parent 79e6ab5 commit ddc1c21

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libstd/macros.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ macro_rules! fail(
149149
// function to pass to format_args!, *and* we need the
150150
// file and line numbers right here; so an inner bare fn
151151
// is our only choice.
152-
#[inline]
152+
//
153+
// LLVM doesn't tend to inline this, presumably because begin_unwind_fmt
154+
// is #[cold] and #[inline(never)] and because this is flagged as cold
155+
// as returning !. We really do want this to be inlined, however,
156+
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
157+
// were seen when forcing this to be inlined, and that number just goes
158+
// up with the number of calls to fail!()
159+
#[inline(always)]
153160
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
154161
::std::rt::begin_unwind_fmt(fmt, file!(), line!())
155162
}

0 commit comments

Comments
 (0)