From 27b7401a74bc6ed00e8b63641279df481be0399b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 31 Aug 2023 16:57:59 -0700 Subject: [PATCH 1/2] Revert a MIR inlining change for ppc64le --- ...e-always-part-of-inline-always-in-MI.patch | 41 +++++++++++++++++++ rust.spec | 4 ++ 2 files changed, 45 insertions(+) create mode 100644 0001-Revert-Ignore-the-always-part-of-inline-always-in-MI.patch diff --git a/0001-Revert-Ignore-the-always-part-of-inline-always-in-MI.patch b/0001-Revert-Ignore-the-always-part-of-inline-always-in-MI.patch new file mode 100644 index 0000000..d0a2c03 --- /dev/null +++ b/0001-Revert-Ignore-the-always-part-of-inline-always-in-MI.patch @@ -0,0 +1,41 @@ +From b7bf16f803f7913cb1c942133d3f31053c79ad9a Mon Sep 17 00:00:00 2001 +From: Josh Stone +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 b6578cb259ac..8939a26f2ab9 100644 +--- a/compiler/rustc_mir_transform/src/inline.rs ++++ b/compiler/rustc_mir_transform/src/inline.rs +@@ -483,12 +483,11 @@ fn check_mir_body( + // Abort if type validation found anything fishy. + checker.validation?; + +- // 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 + diff --git a/rust.spec b/rust.spec index de93f40..dd01c45 100644 --- a/rust.spec +++ b/rust.spec @@ -123,6 +123,9 @@ Patch5: 0001-Don-t-fail-early-if-try_run-returns-an-error.patch # https://github.com/rust-lang/rust/pull/115109 Patch6: 0001-Skip-ExpandYamlAnchors-when-the-config-is-missing.patch +# Revert a MIR inlining change that broke ppc64le with LLVM 15. +Patch7: 0001-Revert-Ignore-the-always-part-of-inline-always-in-MI.patch + ### RHEL-specific patches below ### # Simple rpm macros for rust-toolset (as opposed to full rust-packaging) @@ -600,6 +603,7 @@ test -f '%{local_rust_root}/bin/rustc' %patch -P4 -p1 %patch -P5 -p1 %patch -P6 -p1 +%patch -P7 -p1 %if %with disabled_libssh2 %patch -P100 -p1 From da4ec08f740271a12c2fdcf6337093b0054edc9c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 5 Oct 2023 16:02:32 -0700 Subject: [PATCH 2/2] Loosen the search for older libclang_rt.profile --- rust.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust.spec b/rust.spec index d1940f3..be6be14 100644 --- a/rust.spec +++ b/rust.spec @@ -725,7 +725,7 @@ fi %define profiler %{clang_resource_dir}/lib/%{_arch}-redhat-linux-gnu/libclang_rt.profile.a %else # The exact profiler path is version dependent.. -%define profiler %(echo %{_libdir}/clang/??/lib/libclang_rt.profile-%{_arch}.a) +%define profiler %(echo %{_libdir}/clang/??/lib/libclang_rt.profile-*.a) %endif test -r "%{profiler}"