diff -Nru rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/changelog rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/changelog --- rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/changelog 2022-04-29 08:28:30.000000000 +0000 +++ rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/changelog 2022-06-07 14:17:36.000000000 +0000 @@ -1,3 +1,10 @@ +rustc (1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~21.10.2) impish; urgency=medium + + * d/p/u-revert-92419.patch: cherry-picked to fix a big performance + regression on s390x. + + -- Simon Chopin Tue, 07 Jun 2022 16:17:36 +0200 + rustc (1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~21.10.1) impish; urgency=medium * Backport to Impish (LP: #1968345) diff -Nru rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/series rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/series --- rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/series 2022-04-29 08:28:30.000000000 +0000 +++ rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/series 2022-06-07 14:15:27.000000000 +0000 @@ -6,6 +6,8 @@ u-ignore-endian-big-diff.patch u-linkchecker-symlinks.patch +u-revert-92419.patch + # not forwarded, or forwarded but unlikely to be merged u-ignore-ppc-hangs.patch u-ignore-bpf-test.patch diff -Nru rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/u-revert-92419.patch rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/u-revert-92419.patch --- rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/u-revert-92419.patch 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.59.0+dfsg1~ubuntu1~llvm/debian/patches/u-revert-92419.patch 2022-06-07 14:15:27.000000000 +0000 @@ -0,0 +1,206 @@ +From: Erik Desjardins +Date: Sat, 26 Feb 2022 12:52:07 -0500 +Origin: https://github.com/rust-lang/rust/pull/94402 +Applied-upstream: 1.61.0 +From 71821418a31a7fd3a58d97544fe265442ed9808d Mon Sep 17 00:00:00 2001 +Subject: [PATCH] Revert "Auto merge of #92419 - erikdesjardins:coldland, + r=nagisa" + +This reverts commit 4f49627c6fe2a32d1fed6310466bb0e1c535c0c0, reversing +changes made to 028c6f1454787c068ff5117e9000a1de4fd98374. + +(This revert patch has been re-issued directly from a `git revert` +command applied onto 1.59 to help with gnarly merge conflicts) +--- + compiler/rustc_codegen_gcc/src/builder.rs | 2 +- + compiler/rustc_codegen_llvm/src/builder.rs | 11 +----- + compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 2 - + compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 --- + compiler/rustc_codegen_ssa/src/mir/block.rs | 6 ++- + .../rustc_codegen_ssa/src/traits/builder.rs | 2 +- + .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 8 ---- + src/test/codegen/unwind-landingpad-cold.rs | 15 -------- + src/test/codegen/unwind-landingpad-inline.rs | 37 ------------------- + 9 files changed, 9 insertions(+), 80 deletions(-) + delete mode 100644 src/test/codegen/unwind-landingpad-cold.rs + delete mode 100644 src/test/codegen/unwind-landingpad-inline.rs + +diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs +index 379c88bbd40..ccf8123000c 100644 +--- a/compiler/rustc_codegen_gcc/src/builder.rs ++++ b/compiler/rustc_codegen_gcc/src/builder.rs +@@ -1403,7 +1403,7 @@ fn cx(&self) -> &CodegenCx<'gcc, 'tcx> { + self.cx + } + +- fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) { ++ fn do_not_inline(&mut self, _llret: RValue<'gcc>) { + unimplemented!(); + } + +diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs +index 5217fa2758f..8c3054b23ff 100644 +--- a/compiler/rustc_codegen_llvm/src/builder.rs ++++ b/compiler/rustc_codegen_llvm/src/builder.rs +@@ -1201,15 +1201,8 @@ fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED) } + } + +- fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) { +- // Cleanup is always the cold path. +- llvm::Attribute::Cold.apply_callsite(llvm::AttributePlace::Function, llret); +- +- // In LLVM versions with deferred inlining (currently, system LLVM < 14), +- // inlining drop glue can lead to exponential size blowup, see #41696 and #92110. +- if !llvm_util::is_rust_llvm() && llvm_util::get_version() < (14, 0, 0) { +- llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret); +- } ++ fn do_not_inline(&mut self, llret: &'ll Value) { ++ llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret); + } + } + +diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +index f2782f84f55..2a114d175f4 100644 +--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs ++++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +@@ -1902,8 +1902,6 @@ pub fn LLVMRustCoverageWriteMappingToBuffer( + pub fn LLVMRustVersionMinor() -> u32; + pub fn LLVMRustVersionPatch() -> u32; + +- pub fn LLVMRustIsRustLLVM() -> bool; +- + pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32); + + pub fn LLVMRustMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value; +diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs +index d49df29f453..71834b20fb7 100644 +--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs ++++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs +@@ -223,12 +223,6 @@ pub fn get_version() -> (u32, u32, u32) { + } + } + +-/// Returns `true` if this LLVM is Rust's bundled LLVM (and not system LLVM). +-pub fn is_rust_llvm() -> bool { +- // Can be called without initializing LLVM +- unsafe { llvm::LLVMRustIsRustLLVM() } +-} +- + pub fn print_passes() { + // Can be called without initializing LLVM + unsafe { +diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs +index dcfe5fcc2ca..e914e493269 100644 +--- a/compiler/rustc_codegen_ssa/src/mir/block.rs ++++ b/compiler/rustc_codegen_ssa/src/mir/block.rs +@@ -160,7 +160,11 @@ fn do_call>( + let llret = bx.call(fn_ty, fn_ptr, &llargs, self.funclet(fx)); + bx.apply_attrs_callsite(&fn_abi, llret); + if fx.mir[self.bb].is_cleanup { +- bx.apply_attrs_to_cleanup_callsite(llret); ++ // Cleanup is always the cold path. Don't inline ++ // drop glue. Also, when there is a deeply-nested ++ // struct, there are "symmetry" issues that cause ++ // exponential inlining - see issue #41696. ++ bx.do_not_inline(llret); + } + + if let Some((ret_dest, target)) = destination { +diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs +index 48d88095855..158e658301e 100644 +--- a/compiler/rustc_codegen_ssa/src/traits/builder.rs ++++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs +@@ -311,5 +311,5 @@ fn call( + ) -> Self::Value; + fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + +- fn apply_attrs_to_cleanup_callsite(&mut self, llret: Self::Value); ++ fn do_not_inline(&mut self, llret: Self::Value); + } +diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +index c21e4acbefe..cf2695be3b5 100644 +--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp ++++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +@@ -714,14 +714,6 @@ extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; } + + extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; } + +-extern "C" bool LLVMRustIsRustLLVM() { +-#ifdef LLVM_RUSTLLVM +- return true; +-#else +- return false; +-#endif +-} +- + extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M, const char *Name, + uint32_t Value) { + unwrap(M)->addModuleFlag(Module::Warning, Name, Value); +diff --git a/src/test/codegen/unwind-landingpad-cold.rs b/src/test/codegen/unwind-landingpad-cold.rs +deleted file mode 100644 +index 650d5b230f4..00000000000 +--- a/src/test/codegen/unwind-landingpad-cold.rs ++++ /dev/null +@@ -1,15 +0,0 @@ +-// no-system-llvm: needs #92110 +-// compile-flags: -Cno-prepopulate-passes +-#![crate_type = "lib"] +- +-// This test checks that drop calls in unwind landing pads +-// get the `cold` attribute. +- +-// CHECK-LABEL: @check_cold +-// CHECK: call void {{.+}}drop_in_place{{.+}} [[ATTRIBUTES:#[0-9]+]] +-// CHECK: attributes [[ATTRIBUTES]] = { cold } +-#[no_mangle] +-pub fn check_cold(f: fn(), x: Box) { +- // this may unwind +- f(); +-} +diff --git a/src/test/codegen/unwind-landingpad-inline.rs b/src/test/codegen/unwind-landingpad-inline.rs +deleted file mode 100644 +index ce78d075dd0..00000000000 +--- a/src/test/codegen/unwind-landingpad-inline.rs ++++ /dev/null +@@ -1,37 +0,0 @@ +-// no-system-llvm: needs #92110 + patch for Rust alloc/dealloc functions +-// compile-flags: -Copt-level=3 +-#![crate_type = "lib"] +- +-// This test checks that we can inline drop_in_place in +-// unwind landing pads. +- +-// Without inlining, the box pointers escape via the call to drop_in_place, +-// and LLVM will not optimize out the pointer comparison. +-// With inlining, everything should be optimized out. +-// See https://github.com/rust-lang/rust/issues/46515 +-// CHECK-LABEL: @check_no_escape_in_landingpad +-// CHECK: start: +-// CHECK-NEXT: ret void +-#[no_mangle] +-pub fn check_no_escape_in_landingpad(f: fn()) { +- let x = &*Box::new(0); +- let y = &*Box::new(0); +- +- if x as *const _ == y as *const _ { +- f(); +- } +-} +- +-// Without inlining, the compiler can't tell that +-// dropping an empty string (in a landing pad) does nothing. +-// With inlining, the landing pad should be optimized out. +-// See https://github.com/rust-lang/rust/issues/87055 +-// CHECK-LABEL: @check_eliminate_noop_drop +-// CHECK: start: +-// CHECK-NEXT: call void %g() +-// CHECK-NEXT: ret void +-#[no_mangle] +-pub fn check_eliminate_noop_drop(g: fn()) { +- let _var = String::new(); +- g(); +-} +-- +2.32.0 +