Skip to content

Commit 6de26f4

Browse files
committed
Auto merge of #42771 - arielb1:no-inline-unwind, r=nagisa
mark calls in the unwind path as !noinline 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 #41696. r? @nagisa
2 parents 622e7e6 + 0b93798 commit 6de26f4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: src/librustc_trans/mir/block.rs

+7
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
146146
} else {
147147
let llret = bcx.call(fn_ptr, &llargs, cleanup_bundle);
148148
fn_ty.apply_attrs_callsite(llret);
149+
if this.mir[bb].is_cleanup {
150+
// Cleanup is always the cold path. Don't inline
151+
// drop glue. Also, when there is a deeply-nested
152+
// struct, there are "symmetry" issues that cause
153+
// exponential inlining - see issue #41696.
154+
llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret);
155+
}
149156

150157
if let Some((ret_dest, ret_ty, target)) = destination {
151158
let op = OperandRef {

Diff for: src/test/run-pass/issue-41696.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010

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

1513
#![feature(test)]
1614

0 commit comments

Comments
 (0)