Skip to content

Commit 851fcc7

Browse files
Revert "Auto merge of rust-lang#92419 - erikdesjardins:coldland, r=nagisa"
This reverts commit 4f49627, reversing changes made to 028c6f1.
1 parent 3b1fe7e commit 851fcc7

File tree

9 files changed

+12
-87
lines changed

9 files changed

+12
-87
lines changed

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

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;
@@ -1175,19 +1174,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11751174
unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED) }
11761175
}
11771176

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

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

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

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

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 {

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

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
}

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,

src/test/codegen/unwind-landingpad-cold.rs

-15
This file was deleted.

src/test/codegen/unwind-landingpad-inline.rs

-37
This file was deleted.

0 commit comments

Comments
 (0)