Skip to content

Commit

Permalink
Revert "Auto merge of rust-lang#92419 - erikdesjardins:coldland, r=na…
Browse files Browse the repository at this point in the history
…gisa"

This reverts commit 4f49627, reversing
changes made to 028c6f1.
  • Loading branch information
erikdesjardins committed Feb 28, 2022
1 parent 3b1fe7e commit 851fcc7
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 87 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, '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!();
}

Expand Down
17 changes: 3 additions & 14 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
use rustc_target::spec::{HasTargetSpec, Target};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::ffi::CStr;
use std::iter;
Expand Down Expand Up @@ -1175,19 +1174,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, UNNAMED) }
}

fn apply_attrs_to_cleanup_callsite(&mut self, llret: &'ll Value) {
let mut attrs = SmallVec::<[_; 2]>::new();

// Cleanup is always the cold path.
attrs.push(llvm::AttributeKind::Cold.create_attr(self.llcx));

// 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) {
attrs.push(llvm::AttributeKind::NoInline.create_attr(self.llcx));
}

attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &attrs);
fn do_not_inline(&mut self, llret: &'ll Value) {
let noinline = llvm::AttributeKind::NoInline.create_attr(self.llcx);
attributes::apply_to_callsite(llret, llvm::AttributePlace::Function, &[noinline]);
}
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,8 +1932,6 @@ extern "C" {
pub fn LLVMRustVersionMinor() -> u32;
pub fn LLVMRustVersionPatch() -> u32;

pub fn LLVMRustIsRustLLVM() -> bool;

/// Add LLVM module flags.
///
/// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,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 {
Expand Down
10 changes: 7 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
bx.invoke(fn_ty, fn_ptr, &llargs, ret_llbb, unwind_block, self.funclet(fx));
bx.apply_attrs_callsite(&fn_abi, invokeret);
if fx.mir[self.bb].is_cleanup {
bx.apply_attrs_to_cleanup_callsite(invokeret);
bx.do_not_inline(invokeret);
}

if let Some((ret_dest, target)) = destination {
Expand All @@ -178,7 +178,11 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
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 {
Expand Down Expand Up @@ -1444,7 +1448,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

let llret = bx.call(fn_ty, fn_ptr, &[], None);
bx.apply_attrs_callsite(&fn_abi, llret);
bx.apply_attrs_to_cleanup_callsite(llret);
bx.do_not_inline(llret);

bx.unreachable();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,5 @@ pub trait BuilderMethods<'a, 'tcx>:
) -> 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);
}
8 changes: 0 additions & 8 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,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,
Module::ModFlagBehavior MergeBehavior,
Expand Down
15 changes: 0 additions & 15 deletions src/test/codegen/unwind-landingpad-cold.rs

This file was deleted.

37 changes: 0 additions & 37 deletions src/test/codegen/unwind-landingpad-inline.rs

This file was deleted.

0 comments on commit 851fcc7

Please sign in to comment.