Skip to content

Commit

Permalink
mark calls in the unwind path as !noinline
Browse files Browse the repository at this point in the history
The unwind path is always cold, so that should not have bad performance
implications.  This avoids catastrophic exponential inlining, and also
decreases the size of librustc.so by 1.5% (OTOH, the size of `libstd.so`
increased by 0.5% for some reason).

Fixes rust-lang#41696.
  • Loading branch information
arielb1 committed Jun 20, 2017
1 parent 1143eb2 commit 0b93798
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/librustc_trans/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
} else {
let llret = bcx.call(fn_ptr, &llargs, cleanup_bundle);
fn_ty.apply_attrs_callsite(llret);
if this.mir[bb].is_cleanup {
// 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.
llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret);
}

if let Some((ret_dest, ret_ty, target)) = destination {
let op = OperandRef {
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/issue-41696.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// except according to those terms.

// this used to cause exponential code-size blowup during LLVM passes.
// ignore-test FIXME #41696
// min-llvm-version 3.9

#![feature(test)]

Expand Down

0 comments on commit 0b93798

Please sign in to comment.