From ddc1c21264898f6a5d12cf03bba30f1f08b73665 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 27 Feb 2014 21:11:50 -0800 Subject: [PATCH] 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!(). --- src/libstd/macros.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 490f2c9b198d..a2e80a180ea3 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -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!()) }