Skip to content

Commit 77f1bec

Browse files
committed
Auto merge of #41920 - arielb1:inline-drop, r=eddyb
remove the #[inline] attribute from drop_in_place Apparently LLVM has exponential code growth while inlining landing pads if that attribute is present. Fixes #41696. beta-nominating because regression. r? @eddyb
2 parents ef3ec5e + 237dbe9 commit 77f1bec

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

src/libcore/ptr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub use intrinsics::write_bytes;
5656
/// invalid pointers, types, and double drops.
5757
#[stable(feature = "drop_in_place", since = "1.8.0")]
5858
#[lang="drop_in_place"]
59-
#[inline]
6059
#[allow(unconditional_recursion)]
6160
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
6261
// Code here does not matter - this is replaced by the

src/librustc_trans/common.rs

+6
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ pub fn requests_inline<'a, 'tcx>(
537537
if is_inline_instance(tcx, instance) {
538538
return true
539539
}
540+
if let ty::InstanceDef::DropGlue(..) = instance.def {
541+
// Drop glue wants to be instantiated at every translation
542+
// unit, but without an #[inline] hint. We should make this
543+
// available to normal end-users.
544+
return true
545+
}
540546
attr::requests_inline(&instance.def.attrs(tcx)[..])
541547
}
542548

src/test/run-pass/issue-41696.rs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// this used to cause exponential code-size blowup during LLVM passes.
12+
// min-llvm-version 3.9
13+
14+
#![feature(test)]
15+
16+
extern crate test;
17+
18+
struct MayUnwind;
19+
20+
impl Drop for MayUnwind {
21+
fn drop(&mut self) {
22+
if test::black_box(false) {
23+
panic!()
24+
}
25+
}
26+
}
27+
28+
struct DS<U> {
29+
may_unwind: MayUnwind,
30+
name: String,
31+
next: U,
32+
}
33+
34+
fn add<U>(ds: DS<U>, name: String) -> DS<DS<U>> {
35+
DS {
36+
may_unwind: MayUnwind,
37+
name: "?".to_owned(),
38+
next: ds,
39+
}
40+
}
41+
42+
fn main() {
43+
let deserializers = DS { may_unwind: MayUnwind, name: "?".to_owned(), next: () };
44+
let deserializers = add(deserializers, "?".to_owned());
45+
let deserializers = add(deserializers, "?".to_owned());
46+
let deserializers = add(deserializers, "?".to_owned());
47+
let deserializers = add(deserializers, "?".to_owned());
48+
let deserializers = add(deserializers, "?".to_owned());
49+
let deserializers = add(deserializers, "?".to_owned());
50+
let deserializers = add(deserializers, "?".to_owned()); // 0.7s
51+
let deserializers = add(deserializers, "?".to_owned()); // 1.3s
52+
let deserializers = add(deserializers, "?".to_owned()); // 2.4s
53+
let deserializers = add(deserializers, "?".to_owned()); // 6.7s
54+
let deserializers = add(deserializers, "?".to_owned()); // 26.0s
55+
let deserializers = add(deserializers, "?".to_owned()); // 114.0s
56+
let deserializers = add(deserializers, "?".to_owned()); // 228.0s
57+
let deserializers = add(deserializers, "?".to_owned()); // 400.0s
58+
let deserializers = add(deserializers, "?".to_owned()); // 800.0s
59+
let deserializers = add(deserializers, "?".to_owned()); // 1600.0s
60+
let deserializers = add(deserializers, "?".to_owned()); // 3200.0s
61+
}

0 commit comments

Comments
 (0)