Blob Blame History Raw
From 816745286555b978e8b0fe05d3bc99d28218587b Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 31 Aug 2023 13:37:23 -0700
Subject: [PATCH] Revert "Ignore the always part of #[inline(always)] in MIR
 inlining"

This reverts part of commit c153f3a356b0e7917c91d3a804b93fadffb778b0.

On Fedora 37 with LLVM 15, we were seeing strange errors from the stage2
rustc on ppc64le, which seemed to imply bad codegen in rustc itself. Git
bisect pointed to this MIR inlining change -- it's not likely the root
cause, since later Fedora with LLVM 16 is working, but this will unblock
us for now.
---
 compiler/rustc_mir_transform/src/inline.rs | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index fc9e18378d5a..800155922b28 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -499,12 +499,11 @@ fn check_mir_body(
             }
         }
 
-        // N.B. We still apply our cost threshold to #[inline(always)] functions.
-        // That attribute is often applied to very large functions that exceed LLVM's (very
-        // generous) inlining threshold. Such functions are very poor MIR inlining candidates.
-        // Always inlining #[inline(always)] functions in MIR, on net, slows down the compiler.
         let cost = checker.cost;
-        if cost <= threshold {
+        if let InlineAttr::Always = callee_attrs.inline {
+            debug!("INLINING {:?} because inline(always) [cost={}]", callsite, cost);
+            Ok(())
+        } else if cost <= threshold {
             debug!("INLINING {:?} [cost={} <= threshold={}]", callsite, cost, threshold);
             Ok(())
         } else {
-- 
2.41.0