Skip to content

Commit b2b3983

Browse files
committed
Remove -Zinline-in-all-cgus
1 parent 64feb9b commit b2b3983

32 files changed

+94
-249
lines changed

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ fn test_unstable_options_tracking_hash() {
792792
tracked!(function_sections, Some(false));
793793
tracked!(human_readable_cgu_names, true);
794794
tracked!(incremental_ignore_spans, true);
795-
tracked!(inline_in_all_cgus, Some(true));
796795
tracked!(inline_mir, Some(true));
797796
tracked!(inline_mir_hint_threshold, Some(123));
798797
tracked!(inline_mir_threshold, Some(123));

compiler/rustc_middle/src/mir/mono.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,8 @@ impl<'tcx> MonoItem<'tcx> {
9191
}
9292

9393
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
94-
let generate_cgu_internal_copies = tcx
95-
.sess
96-
.opts
97-
.unstable_opts
98-
.inline_in_all_cgus
99-
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
100-
&& !tcx.sess.link_dead_code();
94+
let generate_cgu_internal_copies =
95+
(tcx.sess.opts.optimize != OptLevel::No) && !tcx.sess.link_dead_code();
10196

10297
match *self {
10398
MonoItem::Fn(ref instance) => {
@@ -121,8 +116,8 @@ impl<'tcx> MonoItem<'tcx> {
121116
}
122117

123118
// At this point we don't have explicit linkage and we're an
124-
// inlined function. If we're inlining into all CGUs then we'll
125-
// be creating a local copy per CGU.
119+
// inlined function. If this crate's build settings permit,
120+
// we'll be creating a local copy per CGU.
126121
if generate_cgu_internal_copies {
127122
return InstantiationMode::LocalCopy;
128123
}

compiler/rustc_session/src/options.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1821,8 +1821,6 @@ options! {
18211821
"verify extended properties for incr. comp. (default: no):
18221822
- hashes of green query instances
18231823
- hash collisions of query keys"),
1824-
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1825-
"control whether `#[inline]` functions are in all CGUs"),
18261824
inline_llvm: bool = (true, parse_bool, [TRACKED],
18271825
"enable LLVM inlining (default: yes)"),
18281826
inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],

tests/codegen-units/item-collection/drop_in_place_intrinsic.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//
21
//@ compile-flags:-Zprint-mono-items=eager
3-
//@ compile-flags:-Zinline-in-all-cgus
42
//@ compile-flags:-Zinline-mir=no
53

64
#![feature(start)]

tests/codegen-units/item-collection/generic-drop-glue.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//
21
//@ compile-flags:-Zprint-mono-items=eager
3-
//@ compile-flags:-Zinline-in-all-cgus
42

53
#![deny(dead_code)]
64
#![feature(start)]

tests/codegen-units/item-collection/instantiation-through-vtable.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//
2-
//@ compile-flags:-Zprint-mono-items=eager -Zinline-in-all-cgus -Zmir-opt-level=0
1+
//@ compile-flags:-Zprint-mono-items=eager -Zmir-opt-level=0
32

43
#![deny(dead_code)]
54
#![feature(start)]

tests/codegen-units/item-collection/non-generic-drop-glue.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//
21
//@ compile-flags:-Zprint-mono-items=eager
3-
//@ compile-flags:-Zinline-in-all-cgus
42

53
#![deny(dead_code)]
64
#![feature(start)]

tests/codegen-units/item-collection/transitive-drop-glue.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//
21
//@ compile-flags:-Zprint-mono-items=eager
3-
//@ compile-flags:-Zinline-in-all-cgus
42

53
#![deny(dead_code)]
64
#![feature(start)]

tests/codegen-units/item-collection/tuple-drop-glue.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//
21
//@ compile-flags:-Zprint-mono-items=eager
3-
//@ compile-flags:-Zinline-in-all-cgus
42

53
#![deny(dead_code)]
64
#![feature(start)]

tests/codegen-units/item-collection/unsizing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags:-Zprint-mono-items=eager
2-
//@ compile-flags:-Zinline-in-all-cgus
32
//@ compile-flags:-Zmir-opt-level=0
43

54
#![deny(dead_code)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# codegen-units/partitioning tests
2+
3+
This test suite is designed to test that codegen unit partitioning works as intended.
4+
Note that it does not evaluate whether CGU partitioning is *good*.
5+
6+
All tests in this suite use the flag `-Zprint-mono-items=lazy`, which makes the compiler print a machine-readable summary all MonoItems that were collected and which CGUs they were assigned to and the linkage in each CGU, in the format:
7+
```
8+
MONO_ITEM <item> @@ <cgu name>[<linkage>] <other cgu name>[<linkage in other cgu>]
9+
```

tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
22
// prevent drop-glue from participating in share-generics.
33
//@ compile-flags:-Zshare-generics=yes -Copt-level=0
4-
//@ no-prefer-dynamic
54

65
#![crate_type = "rlib"]
76

tests/codegen-units/partitioning/extern-drop-glue.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
// We specify incremental here because we want to test the partitioning for incremental compilation
2-
// We specify opt-level=0 because `drop_in_place` is `Internal` when optimizing
31
//@ incremental
4-
//@ compile-flags:-Zprint-mono-items=lazy
5-
//@ compile-flags:-Zinline-in-all-cgus -Copt-level=0
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
63

7-
#![allow(dead_code)]
84
#![crate_type = "rlib"]
95

106
//@ aux-build:cgu_extern_drop_glue.rs

tests/codegen-units/partitioning/extern-generic.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
1-
// We specify incremental here because we want to test the partitioning for incremental compilation
21
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y
2+
//@ compile-flags: -Zprint-mono-items=lazy -Zshare-generics=y -Copt-level=0
43

5-
#![allow(dead_code)]
64
#![crate_type = "lib"]
75

86
//@ aux-build:cgu_generic_function.rs
97
extern crate cgu_generic_function;
108

11-
//~ MONO_ITEM fn user @@ extern_generic[Internal]
12-
fn user() {
9+
//~ MONO_ITEM fn user @@ extern_generic[External]
10+
pub fn user() {
1311
let _ = cgu_generic_function::foo("abc");
1412
}
1513

16-
mod mod1 {
14+
pub mod mod1 {
1715
use cgu_generic_function;
1816

19-
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[Internal]
20-
fn user() {
17+
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[External]
18+
pub fn user() {
2119
let _ = cgu_generic_function::foo("abc");
2220
}
2321

24-
mod mod1 {
22+
pub mod mod1 {
2523
use cgu_generic_function;
2624

27-
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[Internal]
28-
fn user() {
25+
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[External]
26+
pub fn user() {
2927
let _ = cgu_generic_function::foo("abc");
3028
}
3129
}
3230
}
3331

34-
mod mod2 {
32+
pub mod mod2 {
3533
use cgu_generic_function;
3634

37-
//~ MONO_ITEM fn mod2::user @@ extern_generic-mod2[Internal]
38-
fn user() {
35+
//~ MONO_ITEM fn mod2::user @@ extern_generic-mod2[External]
36+
pub fn user() {
3937
let _ = cgu_generic_function::foo("abc");
4038
}
4139
}
4240

43-
mod mod3 {
44-
//~ MONO_ITEM fn mod3::non_user @@ extern_generic-mod3[Internal]
45-
fn non_user() {}
41+
pub mod mod3 {
42+
//~ MONO_ITEM fn mod3::non_user @@ extern_generic-mod3[External]
43+
pub fn non_user() {}
4644
}
4745

4846
// Make sure the two generic functions from the extern crate get instantiated

tests/codegen-units/partitioning/incremental-merging.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
// We specify incremental here because we want to test the partitioning for incremental compilation
21
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
4-
//@ compile-flags:-Ccodegen-units=3
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0 -Ccodegen-units=3
53

64
#![crate_type = "rlib"]
75

86
// This test makes sure that merging of CGUs works together with incremental
97
// compilation but at the same time does not modify names of CGUs that were not
108
// affected by merging.
11-
//
12-
// We expect CGUs `aaa` and `bbb` to be merged (because they are the smallest),
13-
// while `ccc` and `ddd` are supposed to stay untouched.
9+
//
10+
// CGU partitioning creates one CGU per module, so with 4 modules and codegen-units=3,
11+
// two of the modules should be merged. We expect CGUs `aaa` and `bbb` to be merged
12+
// (because they are the smallest), while `ccc` and `ddd` should stay untouched.
1413

1514
pub mod aaa {
1615
//~ MONO_ITEM fn aaa::foo @@ incremental_merging-aaa--incremental_merging-bbb[External]

tests/codegen-units/partitioning/inlining-from-extern-crate.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// We specify incremental here because we want to test the partitioning for incremental compilation
21
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
4-
//@ compile-flags:-Zinline-in-all-cgus
2+
//@ compile-flags:-Zprint-mono-items=lazy -Copt-level=1
53

64
#![crate_type = "lib"]
75

tests/codegen-units/partitioning/local-drop-glue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// We specify opt-level=0 because `drop_in_place` is `Internal` when optimizing
33
//@ incremental
44
//@ compile-flags:-Zprint-mono-items=lazy
5-
//@ compile-flags:-Zinline-in-all-cgus -Copt-level=0
5+
//@ compile-flags:-Copt-level=0
66

77
#![allow(dead_code)]
88
#![crate_type = "rlib"]
@@ -33,7 +33,7 @@ pub mod mod1 {
3333
//~ MONO_ITEM fn std::ptr::drop_in_place::<mod1::Struct2> - shim(Some(mod1::Struct2)) @@ local_drop_glue-fallback.cgu[External]
3434
struct Struct2 {
3535
_a: Struct,
36-
//~ MONO_ITEM fn std::ptr::drop_in_place::<(u32, Struct)> - shim(Some((u32, Struct))) @@ local_drop_glue-fallback.cgu[Internal]
36+
//~ MONO_ITEM fn std::ptr::drop_in_place::<(u32, Struct)> - shim(Some((u32, Struct))) @@ local_drop_glue-fallback.cgu[External]
3737
_b: (u32, Struct),
3838
}
3939

tests/codegen-units/partitioning/local-generic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// We specify incremental here because we want to test the partitioning for incremental compilation
22
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=eager
3+
//@ compile-flags:-Zprint-mono-items=eager -Copt-level=0
44

55
#![allow(dead_code)]
66
#![crate_type = "lib"]

tests/codegen-units/partitioning/local-inlining-but-not-all.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// We specify incremental here because we want to test the partitioning for incremental compilation
22
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
4-
//@ compile-flags:-Zinline-in-all-cgus=no
3+
//@ compile-flags:-Zprint-mono-items=lazy -Copt-level=0
54

65
#![allow(dead_code)]
76
#![crate_type = "lib"]

tests/codegen-units/partitioning/local-inlining.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// We specify incremental here because we want to test the partitioning for incremental compilation
22
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
4-
//@ compile-flags:-Zinline-in-all-cgus
3+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
54

65
#![allow(dead_code)]
76
#![crate_type = "lib"]

tests/codegen-units/partitioning/local-transitive-inlining.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// We specify incremental here because we want to test the partitioning for incremental compilation
22
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
4-
//@ compile-flags:-Zinline-in-all-cgus
3+
//@ compile-flags:-Zprint-mono-items=lazy -Copt-level=0
54

65
#![allow(dead_code)]
76
#![crate_type = "rlib"]

tests/codegen-units/partitioning/methods-are-with-self-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// We specify incremental here because we want to test the partitioning for incremental compilation
22
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=lazy
3+
//@ compile-flags:-Zprint-mono-items=lazy -Copt-level=0
44

55
#![crate_type = "lib"]
66

Original file line numberDiff line numberDiff line change
@@ -1,71 +1,69 @@
1-
// We specify incremental here because we want to test the partitioning for incremental compilation
21
//@ incremental
3-
//@ compile-flags:-Zprint-mono-items=eager
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
43

5-
#![allow(dead_code)]
64
#![crate_type = "lib"]
75

8-
//~ MONO_ITEM fn foo @@ regular_modules[Internal]
9-
fn foo() {}
6+
//~ MONO_ITEM fn foo @@ regular_modules[External]
7+
pub fn foo() {}
108

11-
//~ MONO_ITEM fn bar @@ regular_modules[Internal]
12-
fn bar() {}
9+
//~ MONO_ITEM fn bar @@ regular_modules[External]
10+
pub fn bar() {}
1311

14-
//~ MONO_ITEM static BAZ @@ regular_modules[Internal]
15-
static BAZ: u64 = 0;
12+
//~ MONO_ITEM static BAZ @@ regular_modules[External]
13+
pub static BAZ: u64 = 0;
1614

17-
mod mod1 {
15+
pub mod mod1 {
1816

19-
//~ MONO_ITEM fn mod1::foo @@ regular_modules-mod1[Internal]
20-
fn foo() {}
21-
//~ MONO_ITEM fn mod1::bar @@ regular_modules-mod1[Internal]
22-
fn bar() {}
23-
//~ MONO_ITEM static mod1::BAZ @@ regular_modules-mod1[Internal]
24-
static BAZ: u64 = 0;
17+
//~ MONO_ITEM fn mod1::foo @@ regular_modules-mod1[External]
18+
pub fn foo() {}
19+
//~ MONO_ITEM fn mod1::bar @@ regular_modules-mod1[External]
20+
pub fn bar() {}
21+
//~ MONO_ITEM static mod1::BAZ @@ regular_modules-mod1[External]
22+
pub static BAZ: u64 = 0;
2523

26-
mod mod1 {
27-
//~ MONO_ITEM fn mod1::mod1::foo @@ regular_modules-mod1-mod1[Internal]
28-
fn foo() {}
29-
//~ MONO_ITEM fn mod1::mod1::bar @@ regular_modules-mod1-mod1[Internal]
30-
fn bar() {}
31-
//~ MONO_ITEM static mod1::mod1::BAZ @@ regular_modules-mod1-mod1[Internal]
32-
static BAZ: u64 = 0;
24+
pub mod mod1 {
25+
//~ MONO_ITEM fn mod1::mod1::foo @@ regular_modules-mod1-mod1[External]
26+
pub fn foo() {}
27+
//~ MONO_ITEM fn mod1::mod1::bar @@ regular_modules-mod1-mod1[External]
28+
pub fn bar() {}
29+
//~ MONO_ITEM static mod1::mod1::BAZ @@ regular_modules-mod1-mod1[External]
30+
pub static BAZ: u64 = 0;
3331
}
3432

35-
mod mod2 {
36-
//~ MONO_ITEM fn mod1::mod2::foo @@ regular_modules-mod1-mod2[Internal]
37-
fn foo() {}
38-
//~ MONO_ITEM fn mod1::mod2::bar @@ regular_modules-mod1-mod2[Internal]
39-
fn bar() {}
40-
//~ MONO_ITEM static mod1::mod2::BAZ @@ regular_modules-mod1-mod2[Internal]
41-
static BAZ: u64 = 0;
33+
pub mod mod2 {
34+
//~ MONO_ITEM fn mod1::mod2::foo @@ regular_modules-mod1-mod2[External]
35+
pub fn foo() {}
36+
//~ MONO_ITEM fn mod1::mod2::bar @@ regular_modules-mod1-mod2[External]
37+
pub fn bar() {}
38+
//~ MONO_ITEM static mod1::mod2::BAZ @@ regular_modules-mod1-mod2[External]
39+
pub static BAZ: u64 = 0;
4240
}
4341
}
4442

45-
mod mod2 {
43+
pub mod mod2 {
4644

47-
//~ MONO_ITEM fn mod2::foo @@ regular_modules-mod2[Internal]
48-
fn foo() {}
49-
//~ MONO_ITEM fn mod2::bar @@ regular_modules-mod2[Internal]
50-
fn bar() {}
51-
//~ MONO_ITEM static mod2::BAZ @@ regular_modules-mod2[Internal]
52-
static BAZ: u64 = 0;
45+
//~ MONO_ITEM fn mod2::foo @@ regular_modules-mod2[External]
46+
pub fn foo() {}
47+
//~ MONO_ITEM fn mod2::bar @@ regular_modules-mod2[External]
48+
pub fn bar() {}
49+
//~ MONO_ITEM static mod2::BAZ @@ regular_modules-mod2[External]
50+
pub static BAZ: u64 = 0;
5351

54-
mod mod1 {
55-
//~ MONO_ITEM fn mod2::mod1::foo @@ regular_modules-mod2-mod1[Internal]
56-
fn foo() {}
57-
//~ MONO_ITEM fn mod2::mod1::bar @@ regular_modules-mod2-mod1[Internal]
58-
fn bar() {}
59-
//~ MONO_ITEM static mod2::mod1::BAZ @@ regular_modules-mod2-mod1[Internal]
60-
static BAZ: u64 = 0;
52+
pub mod mod1 {
53+
//~ MONO_ITEM fn mod2::mod1::foo @@ regular_modules-mod2-mod1[External]
54+
pub fn foo() {}
55+
//~ MONO_ITEM fn mod2::mod1::bar @@ regular_modules-mod2-mod1[External]
56+
pub fn bar() {}
57+
//~ MONO_ITEM static mod2::mod1::BAZ @@ regular_modules-mod2-mod1[External]
58+
pub static BAZ: u64 = 0;
6159
}
6260

63-
mod mod2 {
64-
//~ MONO_ITEM fn mod2::mod2::foo @@ regular_modules-mod2-mod2[Internal]
65-
fn foo() {}
66-
//~ MONO_ITEM fn mod2::mod2::bar @@ regular_modules-mod2-mod2[Internal]
67-
fn bar() {}
68-
//~ MONO_ITEM static mod2::mod2::BAZ @@ regular_modules-mod2-mod2[Internal]
69-
static BAZ: u64 = 0;
61+
pub mod mod2 {
62+
//~ MONO_ITEM fn mod2::mod2::foo @@ regular_modules-mod2-mod2[External]
63+
pub fn foo() {}
64+
//~ MONO_ITEM fn mod2::mod2::bar @@ regular_modules-mod2-mod2[External]
65+
pub fn bar() {}
66+
//~ MONO_ITEM static mod2::mod2::BAZ @@ regular_modules-mod2-mod2[External]
67+
pub static BAZ: u64 = 0;
7068
}
7169
}

0 commit comments

Comments
 (0)