Skip to content

Commit 4a56cbe

Browse files
committed
Auto merge of rust-lang#94402 - erikdesjardins:revert-coldland, r=nagisa
Revert "Auto merge of rust-lang#92419 - erikdesjardins:coldland, r=nagisa" Should fix (untested) rust-lang#94390 Reopens rust-lang#46515, rust-lang#87055 r? `@ehuss`
2 parents 6e5a6ff + 0c78433 commit 4a56cbe

File tree

10 files changed

+31
-87
lines changed

10 files changed

+31
-87
lines changed

Diff for: compiler/rustc_codegen_gcc/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
14031403
self.cx
14041404
}
14051405

1406-
fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) {
1406+
fn do_not_inline(&mut self, _llret: RValue<'gcc>) {
14071407
unimplemented!();
14081408
}
14091409

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
2323
use rustc_span::Span;
2424
use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
2525
use rustc_target::spec::{HasTargetSpec, Target};
26-
use smallvec::SmallVec;
2726
use std::borrow::Cow;
2827
use std::ffi::CStr;
2928
use std::iter;
@@ -1179,19 +1178,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11791178
unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED) }
11801179
}
11811180

1182-
fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
1183-
let mut attrs = SmallVec::<[_; 2]>::new();
1184-
1185-
// Cleanup is always the cold path.
1186-
attrs.push(llvm::AttributeKind::Cold.create_attr(self.llcx));
1187-
1188-
// In LLVM versions with deferred inlining (currently, system LLVM < 14),
1189-
// inlining drop glue can lead to exponential size blowup, see #41696 and #92110.
1190-
if !llvm_util::is_rust_llvm() && llvm_util::get_version() < (14, 0, 0) {
1191-
attrs.push(llvm::AttributeKind::NoInline.create_attr(self.llcx));
1192-
}
1193-
1194-
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &attrs);
1181+
fn do_not_inline(&mut self, llret: &'ll Value) {
1182+
let noinline = llvm::AttributeKind::NoInline.create_attr(self.llcx);
1183+
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[noinline]);
11951184
}
11961185
}
11971186

Diff for: compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1933,8 +1933,6 @@ extern "C" {
19331933
pub fn LLVMRustVersionMinor() -> u32;
19341934
pub fn LLVMRustVersionPatch() -> u32;
19351935

1936-
pub fn LLVMRustIsRustLLVM() -> bool;
1937-
19381936
/// Add LLVM module flags.
19391937
///
19401938
/// In order for Rust-C LTO to work, module flags must be compatible with Clang. What

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

-6
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,6 @@ pub fn get_version() -> (u32, u32, u32) {
257257
}
258258
}
259259

260-
/// Returns `true` if this LLVM is Rust's bundled LLVM (and not system LLVM).
261-
pub fn is_rust_llvm() -> bool {
262-
// Can be called without initializing LLVM
263-
unsafe { llvm::LLVMRustIsRustLLVM() }
264-
}
265-
266260
pub fn print_passes() {
267261
// Can be called without initializing LLVM
268262
unsafe {

Diff for: compiler/rustc_codegen_ssa/src/mir/block.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
166166
bx.invoke(fn_ty, fn_ptr, &llargs, ret_llbb, unwind_block, self.funclet(fx));
167167
bx.apply_attrs_callsite(&fn_abi, invokeret);
168168
if fx.mir[self.bb].is_cleanup {
169-
bx.apply_attrs_to_cleanup_callsite(invokeret);
169+
bx.do_not_inline(invokeret);
170170
}
171171

172172
if let Some((ret_dest, target)) = destination {
@@ -178,7 +178,11 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
178178
let llret = bx.call(fn_ty, fn_ptr, &llargs, self.funclet(fx));
179179
bx.apply_attrs_callsite(&fn_abi, llret);
180180
if fx.mir[self.bb].is_cleanup {
181-
bx.apply_attrs_to_cleanup_callsite(llret);
181+
// Cleanup is always the cold path. Don't inline
182+
// drop glue. Also, when there is a deeply-nested
183+
// struct, there are "symmetry" issues that cause
184+
// exponential inlining - see issue #41696.
185+
bx.do_not_inline(llret);
182186
}
183187

184188
if let Some((ret_dest, target)) = destination {
@@ -1444,7 +1448,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14441448

14451449
let llret = bx.call(fn_ty, fn_ptr, &[], None);
14461450
bx.apply_attrs_callsite(&fn_abi, llret);
1447-
bx.apply_attrs_to_cleanup_callsite(llret);
1451+
bx.do_not_inline(llret);
14481452

14491453
bx.unreachable();
14501454

Diff for: compiler/rustc_codegen_ssa/src/traits/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,5 +479,5 @@ pub trait BuilderMethods<'a, 'tcx>:
479479
) -> Self::Value;
480480
fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
481481

482-
fn apply_attrs_to_cleanup_callsite(&mut self, llret: Self::Value);
482+
fn do_not_inline(&mut self, llret: Self::Value);
483483
}

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -694,14 +694,6 @@ extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; }
694694

695695
extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; }
696696

697-
extern "C" bool LLVMRustIsRustLLVM() {
698-
#ifdef LLVM_RUSTLLVM
699-
return true;
700-
#else
701-
return false;
702-
#endif
703-
}
704-
705697
extern "C" void LLVMRustAddModuleFlag(
706698
LLVMModuleRef M,
707699
Module::ModFlagBehavior MergeBehavior,

Diff for: src/test/codegen/unwind-landingpad-cold.rs

-15
This file was deleted.

Diff for: src/test/codegen/unwind-landingpad-inline.rs

-37
This file was deleted.

Diff for: src/test/codegen/vec-shrink-panik.rs

+19
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,32 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
1616
// CHECK-LABEL: @issue71861
1717
#[no_mangle]
1818
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
19+
// CHECK-NOT: panic
20+
21+
// Call to panic_no_unwind in case of double-panic is expected,
22+
// but other panics are not.
23+
// CHECK: cleanup
24+
// CHECK-NEXT: ; call core::panicking::panic_no_unwind
25+
// CHECK-NEXT: panic_no_unwind
26+
1927
// CHECK-NOT: panic
2028
vec.into_boxed_slice()
2129
}
2230

2331
// CHECK-LABEL: @issue75636
2432
#[no_mangle]
2533
pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
34+
// CHECK-NOT: panic
35+
36+
// Call to panic_no_unwind in case of double-panic is expected,
37+
// but other panics are not.
38+
// CHECK: cleanup
39+
// CHECK-NEXT: ; call core::panicking::panic_no_unwind
40+
// CHECK-NEXT: panic_no_unwind
41+
2642
// CHECK-NOT: panic
2743
iter.iter().copied().collect()
2844
}
45+
46+
// CHECK: ; core::panicking::panic_no_unwind
47+
// CHECK: declare void @{{.*}}panic_no_unwind

0 commit comments

Comments
 (0)