-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove -Zinline-in-all-cgus and clean up tests/codegen-units/ #133929
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
tests/codegen-units/item-collection/drop_in_place_intrinsic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
tests/codegen-units/item-collection/instantiation-through-vtable.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# codegen-units/partitioning tests | ||
|
||
This test suite is designed to test that codegen unit partitioning works as intended. | ||
Note that it does not evaluate whether CGU partitioning is *good*. That is the job of the compiler benchmark suite. | ||
|
||
All tests in this suite use the flag `-Zprint-mono-items=lazy`, which makes the compiler print a machine-readable summary of all MonoItems that were collected, which CGUs they were assigned to, and the linkage in each CGU. The output looks like: | ||
``` | ||
MONO_ITEM <item> @@ <cgu name>[<linkage>] <other cgu name>[<linkage in other cgu>] | ||
``` | ||
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. | ||
|
||
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. | ||
|
||
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). |
3 changes: 1 addition & 2 deletions
3
tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,36 @@ | ||
// We specify incremental here because we want to test the partitioning for incremental compilation | ||
//@ incremental | ||
//@ compile-flags:-Zprint-mono-items=eager -Zshare-generics=y | ||
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0 | ||
|
||
#![allow(dead_code)] | ||
#![crate_type = "lib"] | ||
|
||
//@ aux-build:cgu_generic_function.rs | ||
extern crate cgu_generic_function; | ||
|
||
//~ MONO_ITEM fn user @@ extern_generic[Internal] | ||
fn user() { | ||
// This test checks that, in an unoptimized build, a generic function and its callees are only | ||
// instantiated once in this crate. | ||
|
||
//~ MONO_ITEM fn user @@ extern_generic[External] | ||
pub fn user() { | ||
let _ = cgu_generic_function::foo("abc"); | ||
} | ||
|
||
mod mod1 { | ||
pub mod mod1 { | ||
use cgu_generic_function; | ||
|
||
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[Internal] | ||
fn user() { | ||
//~ MONO_ITEM fn mod1::user @@ extern_generic-mod1[External] | ||
pub fn user() { | ||
let _ = cgu_generic_function::foo("abc"); | ||
} | ||
|
||
mod mod1 { | ||
pub mod mod1 { | ||
use cgu_generic_function; | ||
|
||
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[Internal] | ||
fn user() { | ||
//~ MONO_ITEM fn mod1::mod1::user @@ extern_generic-mod1-mod1[External] | ||
pub fn user() { | ||
let _ = cgu_generic_function::foo("abc"); | ||
} | ||
} | ||
} | ||
|
||
mod mod2 { | ||
use cgu_generic_function; | ||
|
||
//~ MONO_ITEM fn mod2::user @@ extern_generic-mod2[Internal] | ||
fn user() { | ||
let _ = cgu_generic_function::foo("abc"); | ||
} | ||
} | ||
|
||
mod mod3 { | ||
//~ MONO_ITEM fn mod3::non_user @@ extern_generic-mod3[Internal] | ||
fn non_user() {} | ||
} | ||
|
||
// Make sure the two generic functions from the extern crate get instantiated | ||
// once for the current crate | ||
//~ MONO_ITEM fn cgu_generic_function::foo::<&str> @@ cgu_generic_function-in-extern_generic.volatile[External] | ||
//~ MONO_ITEM fn cgu_generic_function::bar::<&str> @@ cgu_generic_function-in-extern_generic.volatile[External] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//@ incremental | ||
//@ compile-flags: -Zprint-mono-items=lazy -Copt-level=0 | ||
|
||
#![crate_type = "lib"] | ||
|
||
// This test checks that a monomorphic inline(always) function is instantiated in every CGU that | ||
// references it, even though this is an unoptimized incremental build. | ||
// It also checks that an inline(always) function is only placed in CGUs that reference it. | ||
|
||
mod inline { | ||
//~ MONO_ITEM fn inline::inlined_function @@ inline_always-user1[Internal] inline_always-user2[Internal] | ||
#[inline(always)] | ||
pub fn inlined_function() {} | ||
} | ||
|
||
pub mod user1 { | ||
use super::inline; | ||
|
||
//~ MONO_ITEM fn user1::foo @@ inline_always-user1[External] | ||
pub fn foo() { | ||
inline::inlined_function(); | ||
} | ||
} | ||
|
||
pub mod user2 { | ||
use super::inline; | ||
|
||
//~ MONO_ITEM fn user2::bar @@ inline_always-user2[External] | ||
pub fn bar() { | ||
inline::inlined_function(); | ||
} | ||
} | ||
|
||
pub mod non_user { | ||
|
||
//~ MONO_ITEM fn non_user::baz @@ inline_always-non_user[External] | ||
pub fn baz() {} | ||
} |
4 changes: 1 addition & 3 deletions
4
tests/codegen-units/partitioning/inlining-from-extern-crate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these docss 💙