Skip to content

Commit 5dd9c96

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

33 files changed

+108
-277
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*, that is the job of the compiler benchmark suite.
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-2
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.
3-
//@ compile-flags:-Zshare-generics=yes -Copt-level=0
4-
//@ no-prefer-dynamic
3+
//@ compile-flags: -Zshare-generics=yes -Copt-level=0
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

+4-5
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.
119
//
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.
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

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
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
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct> - shim(Some(Struct)) @@ local_drop_glue-fallback.cgu[External]
11-
struct Struct {
7+
pub struct Struct {
128
_a: u32,
139
}
1410

@@ -18,7 +14,7 @@ impl Drop for Struct {
1814
}
1915

2016
//~ MONO_ITEM fn std::ptr::drop_in_place::<Outer> - shim(Some(Outer)) @@ local_drop_glue-fallback.cgu[External]
21-
struct Outer {
17+
pub struct Outer {
2218
_a: Struct,
2319
}
2420

@@ -33,7 +29,7 @@ pub mod mod1 {
3329
//~ MONO_ITEM fn std::ptr::drop_in_place::<mod1::Struct2> - shim(Some(mod1::Struct2)) @@ local_drop_glue-fallback.cgu[External]
3430
struct Struct2 {
3531
_a: Struct,
36-
//~ MONO_ITEM fn std::ptr::drop_in_place::<(u32, Struct)> - shim(Some((u32, Struct))) @@ local_drop_glue-fallback.cgu[Internal]
32+
//~ MONO_ITEM fn std::ptr::drop_in_place::<(u32, Struct)> - shim(Some((u32, Struct))) @@ local_drop_glue-fallback.cgu[External]
3733
_b: (u32, Struct),
3834
}
3935

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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

86
//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
@@ -13,34 +11,34 @@ pub fn generic<T>(x: T) -> T {
1311
x
1412
}
1513

16-
//~ MONO_ITEM fn user @@ local_generic[Internal]
17-
fn user() {
14+
//~ MONO_ITEM fn user @@ local_generic[External]
15+
pub fn user() {
1816
let _ = generic(0u32);
1917
}
2018

21-
mod mod1 {
19+
pub mod mod1 {
2220
pub use super::generic;
2321

24-
//~ MONO_ITEM fn mod1::user @@ local_generic-mod1[Internal]
25-
fn user() {
22+
//~ MONO_ITEM fn mod1::user @@ local_generic-mod1[External]
23+
pub fn user() {
2624
let _ = generic(0u64);
2725
}
2826

29-
mod mod1 {
27+
pub mod mod1 {
3028
use super::generic;
3129

32-
//~ MONO_ITEM fn mod1::mod1::user @@ local_generic-mod1-mod1[Internal]
33-
fn user() {
30+
//~ MONO_ITEM fn mod1::mod1::user @@ local_generic-mod1-mod1[External]
31+
pub fn user() {
3432
let _ = generic('c');
3533
}
3634
}
3735
}
3836

39-
mod mod2 {
37+
pub mod mod2 {
4038
use super::generic;
4139

42-
//~ MONO_ITEM fn mod2::user @@ local_generic-mod2[Internal]
43-
fn user() {
40+
//~ MONO_ITEM fn mod2::user @@ local_generic-mod2[External]
41+
pub fn user() {
4442
let _ = generic("abc");
4543
}
4644
}

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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=no
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
53

6-
#![allow(dead_code)]
74
#![crate_type = "lib"]
85

96
mod inline {

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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=0
53

6-
#![allow(dead_code)]
74
#![crate_type = "lib"]
85

96
mod inline {

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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=0
53

6-
#![allow(dead_code)]
74
#![crate_type = "rlib"]
85

96
mod inline {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +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
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
43

54
#![crate_type = "lib"]
65

0 commit comments

Comments
 (0)