Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 512b3e3

Browse files
committedJan 21, 2025·
Remove -Zinline-in-all-cgus and clean up CGU partitioning tests
1 parent ed43cbc commit 512b3e3

34 files changed

+182
-367
lines changed
 

‎compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ fn test_unstable_options_tracking_hash() {
795795
tracked!(function_sections, Some(false));
796796
tracked!(human_readable_cgu_names, true);
797797
tracked!(incremental_ignore_spans, true);
798-
tracked!(inline_in_all_cgus, Some(true));
799798
tracked!(inline_mir, Some(true));
800799
tracked!(inline_mir_hint_threshold, Some(123));
801800
tracked!(inline_mir_threshold, Some(123));

‎compiler/rustc_middle/src/mir/mono.rs

Lines changed: 4 additions & 9 deletions
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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,8 +1870,6 @@ options! {
18701870
"verify extended properties for incr. comp. (default: no):
18711871
- hashes of green query instances
18721872
- hash collisions of query keys"),
1873-
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
1874-
"control whether `#[inline]` functions are in all CGUs"),
18751873
inline_llvm: bool = (true, parse_bool, [TRACKED],
18761874
"enable LLVM inlining (default: yes)"),
18771875
inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],

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

Lines changed: 0 additions & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 0 additions & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 1 addition & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 0 additions & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 0 additions & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 0 additions & 2 deletions
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
#![crate_type = "lib"]

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

Lines changed: 0 additions & 1 deletion
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)]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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, which CGUs they were assigned to, and the linkage in each CGU. The output looks like:
7+
```
8+
MONO_ITEM <item> @@ <cgu name>[<linkage>] <other cgu name>[<linkage in other cgu>]
9+
```
10+
DO NOT add tests to this suite that use `-Zprint-mono-items=eager`, that flag changes the way that MonoItem collection works in rather fundamental ways that are otherwise only used by `-Clink-dead-code`, and thus the MonoItems collected and their linkage under `-Zprint-mono-items=eager` does not correlate very well with normal compilation behavior.
11+
12+
The current CGU partitioning algorithm essentially groups MonoItems by which module they are defined in, then merges small CGUs. There are a lot of inline modules in this test suite because that's the only way to observe the partitioning.
13+
14+
Currently, the test suite is very heavily biased towards incremental builds with -Copt-level=0. This is mostly an accident of history; the entire test suite was added as part of supporting incremental compilation in #32779. But also CGU partitioning is *mostly* valuable because the CGU is the unit of incrementality to the codegen backend (cached queries are the unit of incrementality for the rest of the compiler).

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
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
117
extern crate cgu_extern_drop_glue;
128

9+
// This test checks that drop glue is generated, even for types not defined in this crate, and all
10+
// drop glue is put in the fallback CGU.
11+
1312
//~ MONO_ITEM fn std::ptr::drop_in_place::<cgu_extern_drop_glue::Struct> - shim(Some(cgu_extern_drop_glue::Struct)) @@ extern_drop_glue-fallback.cgu[External]
1413

1514
struct LocalStruct(cgu_extern_drop_glue::Struct);
Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,36 @@
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 -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+
// This test checks that, in an unoptimized build, a generic function and its callees are only
10+
// instantiated once in this crate.
11+
12+
//~ MONO_ITEM fn user @@ extern_generic[External]
13+
pub fn user() {
1314
let _ = cgu_generic_function::foo("abc");
1415
}
1516

16-
mod mod1 {
17+
pub mod mod1 {
1718
use cgu_generic_function;
1819

19-
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[Internal]
20-
fn user() {
20+
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[External]
21+
pub fn user() {
2122
let _ = cgu_generic_function::foo("abc");
2223
}
2324

24-
mod mod1 {
25+
pub mod mod1 {
2526
use cgu_generic_function;
2627

27-
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[Internal]
28-
fn user() {
28+
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[External]
29+
pub fn user() {
2930
let _ = cgu_generic_function::foo("abc");
3031
}
3132
}
3233
}
3334

34-
mod mod2 {
35-
use cgu_generic_function;
36-
37-
//~ MONO_ITEM fn mod2::user @@ extern_generic-mod2[Internal]
38-
fn user() {
39-
let _ = cgu_generic_function::foo("abc");
40-
}
41-
}
42-
43-
mod mod3 {
44-
//~ MONO_ITEM fn mod3::non_user @@ extern_generic-mod3[Internal]
45-
fn non_user() {}
46-
}
47-
48-
// Make sure the two generic functions from the extern crate get instantiated
49-
// once for the current crate
5035
//~ MONO_ITEM fn cgu_generic_function::foo::<&str> @@ cgu_generic_function-in-extern_generic.volatile[External]
5136
//~ MONO_ITEM fn cgu_generic_function::bar::<&str> @@ cgu_generic_function-in-extern_generic.volatile[External]

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

Lines changed: 4 additions & 5 deletions
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]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//@ incremental
2+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
3+
4+
#![crate_type = "lib"]
5+
6+
// This test checks that a monomorphic inline(always) function is instantiated in every CGU that
7+
// references it, even though this is an unoptimized incremental build.
8+
// It also checks that an inline(always) function is only placed in CGUs that reference it.
9+
10+
mod inline {
11+
//~ MONO_ITEM fn inline::inlined_function @@ inline_always-user1[Internal] inline_always-user2[Internal]
12+
#[inline(always)]
13+
pub fn inlined_function() {}
14+
}
15+
16+
pub mod user1 {
17+
use super::inline;
18+
19+
//~ MONO_ITEM fn user1::foo @@ inline_always-user1[External]
20+
pub fn foo() {
21+
inline::inlined_function();
22+
}
23+
}
24+
25+
pub mod user2 {
26+
use super::inline;
27+
28+
//~ MONO_ITEM fn user2::bar @@ inline_always-user2[External]
29+
pub fn bar() {
30+
inline::inlined_function();
31+
}
32+
}
33+
34+
pub mod non_user {
35+
36+
//~ MONO_ITEM fn non_user::baz @@ inline_always-non_user[External]
37+
pub fn baz() {}
38+
}

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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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

6+
// This test checks that drop glue is generated for types defined in this crate, and that all drop
7+
// glue is put in the fallback CGU.
8+
// This is rather similar to extern-drop-glue.rs.
9+
1010
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct> - shim(Some(Struct)) @@ local_drop_glue-fallback.cgu[External]
11-
struct Struct {
11+
pub struct Struct {
1212
_a: u32,
1313
}
1414

@@ -18,7 +18,7 @@ impl Drop for Struct {
1818
}
1919

2020
//~ MONO_ITEM fn std::ptr::drop_in_place::<Outer> - shim(Some(Outer)) @@ local_drop_glue-fallback.cgu[External]
21-
struct Outer {
21+
pub struct Outer {
2222
_a: Struct,
2323
}
2424

@@ -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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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

6+
// This test checks that all the instantiations of a local generic fn are placed in the same CGU,
7+
// regardless of where it is called.
8+
89
//~ MONO_ITEM fn generic::<u32> @@ local_generic.volatile[External]
910
//~ MONO_ITEM fn generic::<u64> @@ local_generic.volatile[External]
1011
//~ MONO_ITEM fn generic::<char> @@ local_generic.volatile[External]
@@ -13,34 +14,34 @@ pub fn generic<T>(x: T) -> T {
1314
x
1415
}
1516

16-
//~ MONO_ITEM fn user @@ local_generic[Internal]
17-
fn user() {
17+
//~ MONO_ITEM fn user @@ local_generic[External]
18+
pub fn user() {
1819
let _ = generic(0u32);
1920
}
2021

21-
mod mod1 {
22+
pub mod mod1 {
2223
pub use super::generic;
2324

24-
//~ MONO_ITEM fn mod1::user @@ local_generic-mod1[Internal]
25-
fn user() {
25+
//~ MONO_ITEM fn mod1::user @@ local_generic-mod1[External]
26+
pub fn user() {
2627
let _ = generic(0u64);
2728
}
2829

29-
mod mod1 {
30+
pub mod mod1 {
3031
use super::generic;
3132

32-
//~ MONO_ITEM fn mod1::mod1::user @@ local_generic-mod1-mod1[Internal]
33-
fn user() {
33+
//~ MONO_ITEM fn mod1::mod1::user @@ local_generic-mod1-mod1[External]
34+
pub fn user() {
3435
let _ = generic('c');
3536
}
3637
}
3738
}
3839

39-
mod mod2 {
40+
pub mod mod2 {
4041
use super::generic;
4142

42-
//~ MONO_ITEM fn mod2::user @@ local_generic-mod2[Internal]
43-
fn user() {
43+
//~ MONO_ITEM fn mod2::user @@ local_generic-mod2[External]
44+
pub fn user() {
4445
let _ = generic("abc");
4546
}
4647
}

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

Lines changed: 0 additions & 38 deletions
This file was deleted.

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

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
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

6+
// This test checks that a monomorphic inline(always) function is instantiated in every CGU that
7+
// references it, even if it is only referenced via another module.
8+
// The modules `inline` and `direct_user` do not get CGUs because they only define inline(always)
9+
// functions, which always get lazy codegen.
10+
911
mod inline {
1012

1113
//~ MONO_ITEM fn inline::inlined_function @@ local_transitive_inlining-indirect_user[Internal]
1214
#[inline(always)]
1315
pub fn inlined_function() {}
1416
}
1517

16-
mod direct_user {
18+
pub mod direct_user {
1719
use super::inline;
1820

1921
//~ MONO_ITEM fn direct_user::foo @@ local_transitive_inlining-indirect_user[Internal]

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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

6+
// This test ensures that methods are assigned to the module where their self-type is defined, not
7+
// where the method is defined.
8+
79
pub struct SomeType;
810

911
struct SomeGenericType<T1, T2>(T1, T2);
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
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+
// This test ensures that regular fn items and statics are assigned to the CGU of their module.
107

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

14-
//~ MONO_ITEM static BAZ @@ regular_modules[Internal]
15-
static BAZ: u64 = 0;
11+
//~ MONO_ITEM fn bar @@ regular_modules[External]
12+
pub fn bar() {}
1613

17-
mod mod1 {
14+
//~ MONO_ITEM static BAZ @@ regular_modules[External]
15+
pub static BAZ: u64 = 0;
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+
pub mod mod1 {
2518

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;
19+
//~ MONO_ITEM fn mod1::foo @@ regular_modules-mod1[External]
20+
pub fn foo() {}
21+
//~ MONO_ITEM fn mod1::bar @@ regular_modules-mod1[External]
22+
pub fn bar() {}
23+
//~ MONO_ITEM static mod1::BAZ @@ regular_modules-mod1[External]
24+
pub static BAZ: u64 = 0;
25+
26+
pub mod mod1 {
27+
//~ MONO_ITEM fn mod1::mod1::foo @@ regular_modules-mod1-mod1[External]
28+
pub fn foo() {}
29+
//~ MONO_ITEM fn mod1::mod1::bar @@ regular_modules-mod1-mod1[External]
30+
pub fn bar() {}
31+
//~ MONO_ITEM static mod1::mod1::BAZ @@ regular_modules-mod1-mod1[External]
32+
pub static BAZ: u64 = 0;
3333
}
3434

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;
35+
pub mod mod2 {
36+
//~ MONO_ITEM fn mod1::mod2::foo @@ regular_modules-mod1-mod2[External]
37+
pub fn foo() {}
38+
//~ MONO_ITEM fn mod1::mod2::bar @@ regular_modules-mod1-mod2[External]
39+
pub fn bar() {}
40+
//~ MONO_ITEM static mod1::mod2::BAZ @@ regular_modules-mod1-mod2[External]
41+
pub static BAZ: u64 = 0;
4242
}
4343
}
4444

45-
mod mod2 {
45+
pub mod mod2 {
4646

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;
47+
//~ MONO_ITEM fn mod2::foo @@ regular_modules-mod2[External]
48+
pub fn foo() {}
49+
//~ MONO_ITEM fn mod2::bar @@ regular_modules-mod2[External]
50+
pub fn bar() {}
51+
//~ MONO_ITEM static mod2::BAZ @@ regular_modules-mod2[External]
52+
pub static BAZ: u64 = 0;
5353

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;
54+
pub mod mod1 {
55+
//~ MONO_ITEM fn mod2::mod1::foo @@ regular_modules-mod2-mod1[External]
56+
pub fn foo() {}
57+
//~ MONO_ITEM fn mod2::mod1::bar @@ regular_modules-mod2-mod1[External]
58+
pub fn bar() {}
59+
//~ MONO_ITEM static mod2::mod1::BAZ @@ regular_modules-mod2-mod1[External]
60+
pub static BAZ: u64 = 0;
6161
}
6262

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;
63+
pub mod mod2 {
64+
//~ MONO_ITEM fn mod2::mod2::foo @@ regular_modules-mod2-mod2[External]
65+
pub fn foo() {}
66+
//~ MONO_ITEM fn mod2::mod2::bar @@ regular_modules-mod2-mod2[External]
67+
pub fn bar() {}
68+
//~ MONO_ITEM static mod2::mod2::BAZ @@ regular_modules-mod2-mod2[External]
69+
pub static BAZ: u64 = 0;
7070
}
7171
}

‎tests/codegen-units/partitioning/shared-generics.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
33
// prevent drop-glue from participating in share-generics.
44
//@ incremental
5-
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Copt-level=0
5+
//@ compile-flags: -Zprint-mono-items=lazy -Zshare-generics=yes -Copt-level=0
66

77
#![crate_type = "rlib"]
88

99
//@ aux-build:shared_generics_aux.rs
1010
extern crate shared_generics_aux;
1111

12+
// This test ensures that when a crate and a dependency are compiled with -Zshare-generics, the
13+
// downstream crate reuses generic instantiations from the dependency, but will still instantiate
14+
// its own copy when instantiating with arguments that the dependency did not.
15+
// Drop glue has a lot of special handling in the compiler, so we check that drop glue is also
16+
// shared.
17+
1218
//~ MONO_ITEM fn foo
1319
pub fn foo() {
1420
//~ MONO_ITEM fn shared_generics_aux::generic_fn::<u16> @@ shared_generics_aux-in-shared_generics.volatile[External]

‎tests/codegen-units/partitioning/statics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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 = "rlib"]
65

6+
// This test ensures that statics are assigned to the correct module when they are defined inside
7+
// of a function.
8+
79
//~ MONO_ITEM static FOO @@ statics[Internal]
810
static FOO: u32 = 0;
911

‎tests/codegen-units/partitioning/vtable-through-const.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
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
52
// Need to disable optimizations to ensure consistent output across all CI runners.
6-
//@ compile-flags:-Copt-level=0
3+
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0
74

8-
// This test case makes sure, that references made through constants are
9-
// recorded properly in the InliningMap.
5+
#![crate_type = "rlib"]
106

11-
#![crate_type = "lib"]
7+
// This test case makes sure that references made through constants cause trait associated methods
8+
// to be monomorphized when required.
129

1310
mod mod1 {
1411
struct NeedsDrop;
@@ -43,7 +40,7 @@ mod mod1 {
4340
x
4441
}
4542

46-
// These are referenced, so they produce mono-items (see start())
43+
// These are referenced, so they produce mono-items (see main)
4744
pub const TRAIT1_REF: &'static Trait1 = &NeedsDrop as &Trait1;
4845
pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &NeedsDrop as &Trait1Gen<u8>;
4946
pub const ID_CHAR: fn(char) -> char = id::<char>;
@@ -77,9 +74,8 @@ mod mod1 {
7774
pub const ID_I64: fn(i64) -> i64 = id::<i64>;
7875
}
7976

80-
//~ MONO_ITEM fn start
81-
#[no_mangle]
82-
pub fn start(_: isize, _: *const *const u8) -> isize {
77+
//~ MONO_ITEM fn main @@ vtable_through_const[External]
78+
pub fn main() {
8379
//~ MONO_ITEM fn <mod1::NeedsDrop as std::ops::Drop>::drop @@ vtable_through_const-fallback.cgu[External]
8480
//~ MONO_ITEM fn std::ptr::drop_in_place::<mod1::NeedsDrop> - shim(Some(mod1::NeedsDrop)) @@ vtable_through_const-fallback.cgu[External]
8581

@@ -103,6 +99,4 @@ pub fn start(_: isize, _: *const *const u8) -> isize {
10399

104100
//~ MONO_ITEM fn mod1::id::<char> @@ vtable_through_const-mod1.volatile[External]
105101
mod1::ID_CHAR('x');
106-
107-
0
108102
}

‎tests/run-make/sepcomp-cci-copies/cci_lib.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎tests/run-make/sepcomp-cci-copies/foo.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎tests/run-make/sepcomp-cci-copies/rmake.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎tests/run-make/sepcomp-inlining/foo.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎tests/run-make/sepcomp-inlining/rmake.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎tests/run-make/sepcomp-separate/foo.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎tests/run-make/sepcomp-separate/rmake.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.